#include<bits/stdc++.h>
using namespace std;
string S,S2;
int N,kol1[29],kol2[29],pref[29][200009];
bool sredpal[200009];
bool moze(int x){
  //cout<<"jel moze "<<x<<endl;
  int nemapara=0;
  if(x>N/2){
    for(char c='a'; c<='z'; c++){
      kol1[c-'a']=pref[c-'a'][x]-pref[c-'a'][0];
      kol2[c-'a']=pref[c-'a'][N]-pref[c-'a'][x];
      //cout<<"koliko ima karaktera "<<c<<" u oba "<<kol1[c-'a']<<" "<<kol2[c-'a']<<endl;
      if( kol1[c-'a']<kol2[c-'a'])return false;
      if((kol1[c-'a']-kol2[c-'a'])%2==1)nemapara++;
    }
    if(nemapara>1)return false;
  }
  if(x<=N/2){
    for(char c='a'; c<='z'; c++){
      kol1[c-'a']=pref[c-'a'][x]-pref[c-'a'][0];
      kol2[c-'a']=pref[c-'a'][N]-pref[c-'a'][N-x];
      //cout<<"koliko ima karaktera "<<c<<" u oba "<<kol1[c-'a']<<" "<<kol2[c-'a']<<endl;
      if(kol1[c-'a']!=kol2[c-'a'])return false;
    }
    if(!sredpal[N-2*x])return false;
  }
  //cout<<"moze : "<<x<<endl;
  return true;
}
int resi(){
  int d=S.size();
  for(int i=0; i<d; i++)
    if(S[i]!=S[d-1-i])break;
    else S[i]=S[d-1-i]='.';
  for(int i=0; i<d; i++)
    if(S[i]!='.')S2.push_back(S[i]);
  //cout<<S<<endl;
  //cout<<S2<<endl;
  if(S2.size()<2)return 1;
  N=S2.size();
  S2="."+S2+"....";

  sredpal[N%2]=true;
  for(int i=N/2; i>=1; i--)
    if(S2[i]!=S2[N+1-i])break;
    else sredpal[(N+1-i)-i+1]=true;
  //cout<<"srednji palindrom : ";
  for(int i=1; i<=N; i++)cout<<sredpal[i]<<" ";
  //cout<<endl;

  int ret=1e9;
  for(int pon=1; pon<=2; pon++){
    ///pref
    for(int i=1; i<=N; i++){
      for(char c='a'; c<='z'; c++)
        pref[c-'a'][i]=pref[c-'a'][i-1];
      pref[S2[i]-'a'][i]++;
    }
    /*
    for(char c='a'; c<='c'; c++){
      cout<<c<<" : ";
      for(int i=1; i<=N; i++)cout<<pref[c-'a'][i]<<" ";
      cout<<endl;
    }
    cout<<endl;
    */
    ///calculate
    for(int i=1; i<=N; i++)
      if(moze(i))ret=min(ret,i);
    //cout<<ret<<endl;
    ///reverse S2
    for(int i=1; i<=N/2; i++)swap(S2[i],S2[N-i+1]);
  }
  return ret;
}
int main(){
  cin>>S;
  cout<<resi()<<endl;
  return 0;
}