#include<bits/stdc++.h>

using namespace std;

string s;
int ima[256],fali[256],l,d;
float sr;
bool valja;
bool paran = false;

int main()
{
    cin>>s;
    sr=(s.size()-1)/2.0;
    //cout<<sr<<endl;
    if(s.size()%2==0) paran=true;
    for(int ia=0,ja=s.size()-1;ia<=ja;ia++,ja--)
    {
        if(s[ia]==s[ja]) continue;
        else
        {
            for(int i=ia,j=ja;i<=ja;i++,j--)  ///leva pocetna
            {
                //cout<<i<<" "<<j<<endl;
                ima[s[i]]++;
                if(i<sr)
                    ima[s[j]]--;
                else if(i>sr)
                    ima[s[i]]++;
                int nepar=0;
                //cout<<"Provera za i = "<<i<<endl;
                for(int k='a';k<='z';k++)
                {
                    //cout<<char(k)<<": "<<ima[k]<<endl;
                    if(ima[k]<=-1) break;
                    if(ima[k]%2==1) nepar++;
                    if(nepar>1) break;
                    if(k=='z') {valja = true; l=i-ia+1;}
                }
                if(valja) break;
            }
            valja=false;
            for(int k='a';k<='z';k++)
            {
                ima[k]=0;
            }
            for(int i=ja,j=ia;i>=ia;i--,j++)  ///desna pocetna
            {
                //cout<<i<<" "<<j<<endl;
                //cout<<i<<" "<<j<<endl;
                ima[s[i]]++;
                //cout<<i<<" "<<sr<<" "<<(i>sr)<<" "<<(i<sr)<<endl;
                if(i>sr)
                    ima[s[j]]--;
                else if(i<sr)
                    ima[s[i]]++;
                int nepar=0;
                //cout<<"Provera za i = "<<i<<endl;
                for(int k='a';k<='z';k++)
                {
                    //cout<<char(k)<<": "<<ima[k]<<endl;
                    if(ima[k]<=-1) break;
                    if(ima[k]%2==1) nepar++;
                    if(nepar>1) break;
                    if(k=='z') {valja = true; d=ja-i+1;}
                }
                if(valja) break;
            }
            valja=false;
            break;
        }
    }
    //cout<<l<<" "<<d<<endl;

    if(min(l,d)==0)
        cout<<1<<endl;
    else
        cout<<min(l,d)<<endl;

    return 0;
}

/**
*/