#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll moda=1000000007;
typedef vector<ll> vl1;
typedef vector<vl1> vl2;
typedef vector<string> vst1;

struct struka
{ll val; ll ind;};
typedef vector<struka> vs1;

bool compa(struka& a, struka& b)
{ if(a.val==b.val) return a.ind<b.ind;
  return a.val<b.val;
}

ll lova(vl1&  veka, ll dole, ll gore, ll val)
{ ll sred;
  while(dole<=gore)
  {sred=(gore+dole)/2;
   if(veka[sred]>=val) gore=sred-1;// real condition !
   else dole=sred+1;
  }
 return dole;
}

ll gcd(ll a,ll b)
{ll t;
  while (b)
  { t= b;
    b = a % b;
    a = t;
  }
return a;
}

ll fast_pow(ll a, ll p)
{ ll res = 1;
  while (p)
   { if ( (p &1) == 0) { a = (a * a); p >>=1; }
     else {  res *=  a;   p--; }
   }
  return res;
}

void radi(ll& q)
{ ll i, j, k, kn, m, n, p, t, l, r, x, y, z, a, b, c, d, e, f, los;
  ll val, pos, tmp, suma, maxa, mina, naso, num, pola, nepar, a2;
  string str1, str2;
  char ch1;
  cin>>str1;
  n=str1.size();
  nepar=n&1;
  vl1 niz(n+1);
  vl2 pref(n+1, vl1(27));
  for(i=1;i<=n;i++)
   { val=str1[i-1]-'a'+1;
     niz[i]=val;
     pref[i][val]=1;
     for(k=1;k<=26;k++) pref[i][k]+=pref[i-1][k];
   }
  i=1;
  pola=n>>1;
  while(i<=pola && niz[i]==niz[n+1-i]) i++;
  a=i;
  if(a>pola) {cout<<"1\n"; return;}
  i=pola;
  while(i>0 && niz[i]==niz[n+1-i]) i--;
  b=i;

  naso=0;
  for(k=1;k<=26;k++)
   { if(pref[b][k]-pref[a-1][k]!=pref[n+1-a][k]-pref[n-b][k])
       {  naso=1; break;}
   }
  if(naso==0) {cout<<b-a+1<<'\n'; return;}

  b=pola+1;
  while(1)
   { //dole
     naso=0;
     for(k=1;k<=26;k++)
      { if(pref[b][k]-pref[a-1][k]<pref[n+1-a][k]-pref[b][k])
         {  naso=1; break;}
      }
     if(naso==0) {cout<<b-a+1<<'\n'; return;}
     //gore
     naso=0;
     for(k=1;k<=26;k++)
      { if(pref[n-b][k]-pref[a-1][k]>pref[n+1-a][k]-pref[n-b][k])
         {  naso=1; break;}
      }
     if(naso==0) {cout<<b-a+1<<'\n'; return;}
     b++;
   }

}

int main()
{ /*
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(nullptr);
  cout<<fixed<<setprecision(15);
  */

  ll t, q;
  //cin>>t;
  t=1;
  for(q=1;q<=t;q++)
   { // cout<<"Case #"<<q<<": ";
     radi(q);
   }
  return 0;
}
/*
abbaaca 4 - 3 6

acaaaaa 3 - 2 4
accaaaa 4 - 3 6

abcdaadcba 0 - 1

abcdaabcda 3 - 2 4
abcdabcda
abcdaaabcda
abcdaaaaabcda
bcdaaaaabcd

abbbbbbaaa 5 - 5 9
abbbaaaaaaa 6 - 2 7
aaabbbbbba
aaaaaaabbba


*/