#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
using namespace std;

const char nl='\n';
const int MOD=1000000007;
const int N=200005;

int n,L,R,d,brL[30],brR[30];
bool ok,ok2;
string s;

void solve(){
    cin>>s;
    n=sz(s);
    L=0;R=n-1;ok=1;
    while(L<R){
        if(s[L]!=s[R]){
            ok=0;
            break;
        }
        L++;R--;
    }
    if(ok)cout<<1<<nl;
    else{
        ok2=1;
        s=s.substr(L,R-L+1);
        d=sz(s);
        for(int i=0;i<d/2;i++)brL[s[i]-'a']++;
        for(int i=d/2+(d&1);i<d;i++)brR[s[i]-'a']++;

        for(int i=0;i<26;i++){
            if(brL[i]!=brR[i])ok2=0;
        }
        if(ok2)cout<<d/2<<nl;
        else cout<<d-1<<nl;
    }
}
int main () {
cin.tie(NULL);
ios_base::sync_with_stdio(false);

int T=1;
//cin>>T;
while(T--){
    solve();
}

return 0;
}