#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
//#define L(x) (sizeof(x) / sizeof(*x))
#define ff(i,a,b) for(int (i) = (a);(i)<(b);(i)++)
#define bff(i,a,b) for(int (i) = (a);(i)>(b);(i)--)
long int typedef li;
long long int typedef lli;

using namespace std;
using namespace __gnu_pbds;

int main()
{
    FAST;

    string t;
    cin>>t;
    int br[26],brpoc[26],brkr[26];
    int n = t.length();
    bool pali = true;
    int poc = -1,kraj = n;
    ff(i,0,26){
        br[i] = 0;
        brpoc[i] = 0;
        brkr[i] = 0;
    }
    ff(i,0,n){
        br[t.at(i)-'a']++;
    }
    ff(i,0,n){
        if(t.at(i) != t.at(n-i-1)){
            if(poc == -1){
                if(br[t.at(i)-'a'] == 1&& i!= ((n-1)/2)){
                    poc = i;
                }
                if(brpoc[t.at(i)-'a'] == (br[t.at(i)-'a']/2)){
                    poc = i;
                }
            }
            pali = false;
        }
        brpoc[t.at(i)-'a']++;
    }
    bff(i,n-1,0){
        if(t.at(i) != t.at(n-i-1)){
            if(kraj == n){
                if(br[t.at(i)-'a'] == 1&& i!= ((n-1)/2)){
                    kraj = i;
                }
                if(brkr[t.at(i)-'a'] == (br[t.at(i)-'a']/2)){
                    kraj = i;
                }
            }
            pali = false;
        }
        brkr[t.at(i)-'a']++;
    }
    if((n-1-kraj) >= poc){
        ff(i,0,poc){
            if(t.at(i) != t.at(n-i-1)){
                poc  = i;
            }
        }
    }else{
        bff(i,n-1,kraj){
            if(t.at(i) != t.at(n-i-1)){
                kraj  = i;
            }
        }
    }
    if(!pali){
        cout<<kraj-poc+1;
    }else{
        cout<<1<<endl;
    }
    return 0;
}