#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    string s; cin >> s;
    int d = s.length();
    int duzina = 1;
    for (int i = 0; i < d; i++)
    {
        if (s[i] != s[d - i - 1]) {
            int l = i;
            int r = d - i - 1;
            int rmax = r; int lmax = l;
            while (l < r) {
                for (int j = l+1; j < r; j++)
                {
                    if (s[l] == s[j])
                    {
                        char c = s[r];
                        s[r] = s[j];
                        s[j] = c;
                        if (rmax < r) rmax = r;
                        break;
                    }
                    if (s[r] == s[j])
                    {
                        char c = s[l];
                        s[l] = s[j];
                        s[j] = c;
                        if (l > lmax) lmax = l;
                        break;
                    }
                }
                l++;
                r--;
            }
            duzina = abs(rmax - i);
            if (duzina != 1) break;
        }
    }
    cout << duzina << endl;
}