#include <iostream>
using namespace std;
main(){
string rec,rec1,palindrom;
int brl=0,brd=0,brdu=0,brlu=0,br=0,duzina1;
cin>>rec;
int duzina = rec.length();
char l = rec[0];
char d = rec[duzina-1];
char i,il,id;
rec1=rec.substr(0,duzina);
while(l==d&&duzina>2){
rec1=rec1.substr(1,duzina-2);
duzina-=2;
l = rec1[0];
d = rec1[duzina-1];
}
i=rec1[br];
while(l==i){
br++;
brl++;
i=rec1[br];
}
br=duzina;
i=rec1[br-1];
while(d==i){
br--;
brd++;
i=rec1[br-1];
}
    il=rec1[0];
    id=rec1[duzina-1];
    for(int k=0;k<duzina;k++){
        if(il==rec1[k]){
            brlu++;
        }
        if(id==rec1[k]){
            brdu++;
        }
    }
if(brl==brd){
    if(brlu>=brdu){
        duzina1=brlu/2;
        rec1=rec1.substr(duzina1,duzina-1);
    }
    else{
        duzina1=brdu/2;
        rec1=rec1.substr(0,duzina-1-duzina1);
    }
}
else if(brl>brd){
    duzina1=brlu/2;
    rec1=rec1.substr(duzina1,duzina-1);
}
else{
    duzina1=brdu/2;
    rec1=rec1.substr(0,duzina-1-duzina1);
}
duzina = rec1.length();
if(rec1.length()==0){
    duzina=1;
}
cout<<duzina;
}