#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int granicadesno=0,granicalevo=0;
    string mistring;
    cin >> mistring;
    vector<int> slova1(128,0);
    vector<int> slova2(128,0);
    vector<int> slova3(128,0);
    for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
        slova1[mistring[i]]++;
        slova2[mistring[j]]++;
    }
    if(mistring.size()%2==1 && (slova1[mistring[mistring.size()/2]]+slova2[mistring[mistring.size()/2]])%2==1/* && abs(slova1[mistring[mistring.size()/2]]-slova2[mistring[mistring.size()/2]])==1*/){
        //cout << "naniiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii   " << mistring[mistring.size()/2] << endl;
        if(slova1[mistring[mistring.size()/2]]-slova2[mistring[mistring.size()/2]]>0 ){
            slova2[mistring[mistring.size()/2]]++;
        }
        else{
            slova1[mistring[mistring.size()/2]]++;
        }
    }
    for(int i='a';i<='z';i++){
        //slova3[i]=slova1[i]-slova2[i];
        if(slova1[i]-slova2[i]<0){
            slova3[i]=-(slova1[i]+slova2[i])/2-1;
        }
        else if(slova1[i]-slova2[i]>0){
            slova3[i]=(slova1[i]+slova2[i])/2+1;
        }
        //cout << "slova 3" <<
    }
    bool nijenadenodesno=true;
    bool nijenadenolevo=true;
    granicadesno=mistring.size();
    granicalevo=mistring.size();
    //for(int i='a';i<='z';i++)
    //    cout << "slova3[" << (char)i << "]=" << slova3[i]<<endl;

    for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
        if(slova3[mistring[i]]>0 && nijenadenolevo){
            if( (--slova3[mistring[i]])==0){
                nijenadenolevo=false;
                granicalevo=i;
            }
        }
        if(slova3[mistring[j]]<0 && nijenadenodesno){
            if((++slova3[mistring[j]])==0 ){
                nijenadenodesno=false;
                granicadesno=j;
            }
        }
    }
    //cout << granicalevo << " " << granicadesno << endl;
    if(!(granicadesno!=mistring.size()) != !(granicalevo!=mistring.size())){
        if(granicadesno-mistring.size()/2<abs(-granicalevo+mistring.size()/2)){
            for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
                if(mistring[j]!=mistring[i]){
                    granicadesno=j;
                    break;
                }
            }
            cout << granicadesno-mistring.size()/2+1 << endl;
        }
        else{
            for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
                if(mistring[j]!=mistring[i]){
                    granicalevo=i;
                    break;
                }
            }
            cout << -granicalevo+mistring.size()/2+1 << endl;
        }
        return 0;
    }
    //cout << granicadesno << " " << granicalevo << endl;
    if(granicadesno!=mistring.size() && granicalevo!=mistring.size()){
        for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
            if(mistring[j]!=mistring[i]){
                if(j-granicadesno<granicalevo-i){
                    granicadesno=j;
                    break;
                }
                else{
                    granicalevo=i;
                    break;
                }
            }
        }
        for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
            if(mistring[j]!=mistring[i]){
                if(j-granicadesno<granicalevo-i)
                    granicadesno=j;
                else
                    granicalevo=i;
                break;
            }
        }
        granicadesno++;
    }
    else{
        for(int i=0,j=mistring.size()-1;i<mistring.size()/2;i++,j--){
            if(mistring[j]!=mistring[i]){
                granicalevo=i;
                break;
            }
        }
        for(int i=(mistring.size()-1)/2,j=(mistring.size()-1)/2+1-mistring.size()%2;i>=0;i--,j++){
            //cout << i << " " << j << endl;
            if(mistring[j]!=mistring[i]){
                //cout << mistring[i] << " " << mistring[j] << endl;
                granicadesno=i+1;
                break;
            }
        }
    }
    //cout << granicalevo << " " << granicadesno << endl;
    if(granicadesno-granicalevo==0){
        cout << 1 << endl;
    }
    else
        cout << granicadesno-granicalevo << endl;
    return 0;
}