#include <iostream>
#include <unordered_map>
#include <cmath>

int max(int a, int b) {
    return (a > b) ? a : b;
}

int odds(std::string pal) {
    std::unordered_map<char, int> a;
    int res = 0;
    for (int i = 0; i < pal.length(); i++) {
        if (a[pal[i]] % 2 == 0) {
            res++;
        }
        else {
            res--;
        }
        a[pal[i]]++;
    }
    return res;
}

int main()
{
    std::string a;
    std::cin >> a;
    int i = 0;
    int odd1 = odds(a);
    while (i < a.length() / 2 && a[i] == a[a.length()-1-i]) {
        i++;
    }
    i--;
    if (i == -1) i++;
    std::string newS = a.substr(i+1, a.length() - 2 - 2 * i);
    if (newS.length() <= 1) {
        std::cout << 1 << std::endl;
        return 0;
    }
    else {
        int index2 = a.length()-1-i;
        int index1 = a.length() - 1 - i;
        int j;
        for (j = i; j < index1; j++) {
            if (a[j] == a[index1]) {
                index1--;
            }
            else {
                if (odds(a.substr(j, index1-j+1)) > 1) {
                    break;
                }
            }
        }
        int res1 = index2 - j;
        int index3 = i;
        int index4 = i;
        for (j = a.length() - 1 - i; j > index4; j--) {
            if (a[j] == a[index4]) {
                index4++;
            }
            else {
                if (odds(a.substr(index4, j - index4 + 1)) > 1) {
                    break;
                }
            }
        }
        int res2 = index3 - j;
        std::cout << max(res1, res2) << std::endl;
    }
    
}