#include <bits/stdc++.h>
#define INF 1000000000
#define MAXN 200010
using namespace std;

int a[MAXN];
int pref[MAXN][26];
vector<int> nz(int i, int j)
{
    vector<int> t(26);
    for(int k = 0; k < 26; k++) t[k] = pref[j][k] - pref[i-1][k];
    return t;
}
vector<int> oduzmi(vector<int> x, vector<int> y) /// x - y
{
    vector<int> t(26);
    for(int i = 0; i < 26; i++) t[i] = x[i] - y[i];
    return t;
}
bool check(vector<int> x)
{
    bool nep = false;
    for(int i = 0; i < 26; i++){
        if(x[i] < 0) return false;
        if(x[i]%2 == 1){
        if(!nep) nep = true;
        else return false;
        }
    } return true;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s; int n = s.size();
    for(int i = 1; i <= n; i++) a[i] = s[i-1] - 'a';
    int al = -1, ar = -1, bl = -1, br = -1;
    for(int i = 1, j = n; i < j; i++, j--){
        if(a[i] != a[j]){
            if(al == -1) al = i, br = j;
            else ar = i, bl = j;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 26; j++){
            pref[i][j] = pref[i-1][j];
        } pref[i][a[i]]++;
    }
    int res = br - al + 1;
    if(nz(al, ar) == nz(bl, br)){cout << ar - al + 1 << endl; return 0;}
    for(int i = bl; i < br; i++)
    {
        if(check(oduzmi(nz(al, i), nz(i+1, br)))){
            res = min(res, i - al + 1);
        }
    }
    for(int i = al + 1; i <= ar; i++)
    {
        if(check(oduzmi(nz(i, br), nz(al, i-1)))){
            res = min(res, br - i + 1);
        }
    }
    cout << res << endl;




    return 0;
}