#include <bits/stdc++.h>

using namespace std;

bool jePalindrom(string s)
{
    int n = s.length(), m = n/2;
    for(int i = 0;i<m;i++)if(s[i]!=s[n-1-i])return false;
        return true;
}

bool mogucPerm(string s, int m, int i)
{
    int n = s.length();
     int a[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
     for(int j = 0; j < m; j++)
     {
         a[s[i+j]-'a']++;
         a[s[n-1-i-j]-'a']--;
     }
     for(int j = 0;j<26;j++) if(a[j]!=0)return false;
     return true;
}

bool permutuj(string s, int m)
{
    int n = s.length();
    for(int i = 0;i<(n-m)/2; i++) if(mogucPerm(s,m,i)) return true;
    return false;
}

string skrati(string s)
{
    int n = s.length(), m = n/2;
    for(int i = 0; i < m; i++) if(s[i]!=s[n - i - 1])return s.substr(i, n - 2 * i);
    if (n%2==0)return "";
    string h(1,s[m]);
    return h;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s; cin>>s;
    s = skrati(s);
    int n = s.length();
    if(jePalindrom(s)){cout<<1; return 0;}
    int l = 1, d = n - 1, m;
    while(d-l>1)
    {
        m = (d+l)/2;
        if(permutuj(s, m)) d = m;
        else l = m;
    }
    cout<<d;
    return 0;
}