#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+45;

int n,a[N];
int pf[N][30];
bool istoc[N];
int l,r,sol = N;

void provp(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 26; j++){
            pf[i][j] = pf[i-1][j]+(a[i] == j);
        }
    }

    istoc[n/2] = (a[n/2] == a[n/2 + 1]);
    for(int i = n/2 - 1; i >= 1; i--){
        istoc[i] = istoc[i+1] && (a[i] == a[n-i+1]);
    }

    for(int i = l+1; i <= n/2; i++){
        bool ok = 1;
        for(int j = 1; j <= 26; j++){
            int levo = pf[i][j]-pf[l-1][j];
            int desno = pf[r][j]-pf[r-(i-l)-1][j];
            if(levo != desno){
                ok = 0;
                break;
            }
        }

        if(i < n/2) ok &= istoc[i+1];

        if(ok) sol = min(sol,i-l+1);
    }
    for(int i = n/2 + 1; i <= r; i++){
        bool ok = 1;
        for(int j = 1; j <= 26; j++){
            int desno = pf[r][j]-pf[i][j];
            int ima = pf[i][j]-pf[l-1][j];
            if(ima < desno){
                ok = 0;
                break;
            }
            int ost = ima-desno;
            if(ost&1){
                ok = 0;
                break;
            }
        }

        if(ok) sol = min(sol,i-l+1);
    }
}

void provn(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 26; j++){
            pf[i][j] = pf[i-1][j]+(a[i] == j);
        }
    }

    istoc[n/2 + 1] = 1;
    for(int i = n/2; i >= 1; i--){
        istoc[i] = istoc[i+1] && (a[i] == a[n-i+1]);
    }

    for(int i = l+1; i <= n/2; i++){
        bool ok = 1;
        for(int j = 1; j <= 26; j++){
            int levo = pf[i][j]-pf[l-1][j];
            int desno = pf[r][j]-pf[r-(i-l)-1][j];
            if(levo != desno){
                ok = 0;
                break;
            }
        }

        ok &= istoc[i+1];

        if(ok) sol = min(sol,i-l+1);
    }
    for(int i = n/2 + 1; i <= r; i++){
        bool ok = 1;
        bool bio = 0;
        for(int j = 1; j <= 26; j++){
            int desno = pf[r][j]-pf[i][j];
            int ima = pf[i][j]-pf[l-1][j];
            if(ima < desno){
                ok = 0;
                break;
            }
            int ost = ima-desno;
            if(ost&1){
                if(bio){
                    ok = 0;
                    break;
                }
                bio = 1;
            }
        }

        if(ok) sol = min(sol,i-l+1);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    n = s.size();
    for(int i = 0; i < n; i++) a[i+1] = s[i]-'a'+1;

    string t = s;
    reverse(s.begin(),s.end());
    if(s == t){
        cout << 1 << endl;
        return 0;
    }

    l = 1,r = n;
    while(l < r && a[l] == a[r]){
        l++;
        r--;
    }

    sol = N;
    if(n&1){
        provn();
        for(int i = 1; i <= n/2; i++) swap(a[i],a[n-i+1]);
        provn();
    }
    else{
        provp();
        for(int i = 1; i <= n/2; i++) swap(a[i],a[n-i+1]);
        provp();
    }

    cout << sol << endl;
}