#include<bits/stdc++.h>

using namespace std;

bool provera(vector<vector<long long>>& slova, long long n, long long i, long long j){
    for(long long z = 0 ; z < 28 ; z++){
        long long k = n - i + 1, l = n - j + 1;
        if(l > k) swap(k, l);
        long long uPalindrom = slova[k][z] - slova[l - 1][z];
        long long uOpsek = slova[j][z] - slova[i - 1][z];
        if(i < l && j < k) uPalindrom -= (slova[j][z] - slova[l - 1][z]);
        else uPalindrom -= (slova[k][z] - slova[i - 1][z]);
        if((uOpsek + uPalindrom) % 2 != 0 || uOpsek < uPalindrom){
            if(n % 2 == 0 || slova[n][z] % 2 == 0) return false;
            else if(!(n / 2 + 1 >= i && n / 2 + 1 <= j)) return false;
            else if(uOpsek % 2 == 0) return false;
        }
    }
    return true;
}

int main(){
    string rec;
    cin >> rec;

    vector<vector<long long>> slova(rec.size() + 1, vector<long long> (28));
    for(long long i = 1 ; i <= rec.size() ; i++){
        for(long long j = 0 ; j < 28 ; j++){
            slova[i][j] = slova[i - 1][j];
            if(rec[i - 1] - 'a' == j) slova[i][j]++;
        }
    }

    long long l = 0, r = rec.size() - 1;
    bool fix = false;
    while(l < r){
        if(rec[l] == rec[r]){
            l++;
            r--;
        }
        else break;
    }
    if(l >= r){
        cout << 1;
        return 0;
    }
    long long i = l, j = r;
    while(i < j && provera(slova, rec.size(), i + 1, j + 1)){
        i++;
    }
    long long ans = j - i + 2;

    i = l, j = r;
    while(j > i && provera(slova, rec.size(), i + 1, j + 1)){
        j--;
    }
    ans = min(ans, j - i + 2);
    cout << ans;
    return 0;
}