#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll br[30],br1[30];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    for (ll i=0;i<s.size();i++)
        br[s[i]-'a']++;
    ll l=0,r=s.size()-1,brl=LLONG_MAX,brr=LLONG_MAX;
    while (l<=r)
    {
        if (s[l]==s[r])
        {
            br[s[l]-'a']-=2;
            l++;
            r--;
            continue;
        }
        break;
    }
    if (l>r)
    {
        cout << 1 << "\n";
        return 0;
    }
    ll l1=l,r1=r,brt1[30]={0},brt2[30]={0};
    while (true)
    {
        char c=s[l1];
        if (2*(brt1[c-'a']+1)>br[c-'a'])
        {
            if (br[c-'a']%2==1 && l1==s.size()/2)
            {
                brt1[c-'a']++;
                l1++;
                continue;
            }
            brl=r1-l1+1;
            break;
        }
        brt1[c-'a']++;
        l1++;
    }
    while (true)
    {
        char c=s[r];
        if (2*(brt2[c-'a']+1)>br[c-'a'])
        {
            if (br[c-'a']%2==1 && r==s.size()/2)
            {
                brt2[s[r]-'a']++;
                r--;
                continue;
            }
            brr=r-l+1;
            break;
        }
        brt2[s[r]-'a']++;
        r--;
    }
    cout << min(brl,brr) << "\n";
    return 0;
}