#include <bits/stdc++.h>

using namespace std;

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

    int l = 0;
    int d = s.length() - 1;

    int razlicit = 0;

    int l_min = 10000;
    int d_max = -100;

    int res = 0;

    while(razlicit == 0 && l <= d) {
        if(s[l] == s[d]) {
            l++;
            d--;
        }
        else
            razlicit++;
    }

    if(l > d)
        res = 1;

    if(razlicit > 0) {
        while(l <= d) {
            int x1, x2;
            for(int i = l + 1; i < d; i++)
                if(s[i] == s[d]) {
                    x1 = i;
                    break; }

            for(int i = d - 1; i > l; i--)
                if(s[i] == s[l]) {
                    x2 = i;
                    break; }

            if(abs(x1 - l) > abs(d - x2)) {
                l_min = min(l_min, x2);
                d_max = max(d_max, d);
                int tmp;
                tmp = s[d];
                s[d] = s[x2];
                s[x2] = tmp; }

            else {
                l_min = min(l_min, l);
                d_max = max(d_max, x1);
                int tmp = s[l];
                s[l] = s[x1];
                s[x1] = tmp;
            }

            int razlicito = 0;

            while(razlicito == 0 && l <= d) {
                if(s[l] == s[d]) {
                    l++;
                    d--;
            }
            else
                razlicito++; }
        }
        res = d_max - l_min + 1;
         }

    cout << res << endl;
    return 0;
}