#include <iostream>

using namespace std;

int findMatch(string T, bool matched[], int k, int match, int index[]) {
    matched[k] = true;
    for(int i = T.length() - match - 1; i > max(k, index[((int) T[i])-97]); i--)
        if(!matched[i] && T[i] == T[k]) {
            matched[i] = true;
            index[((int) T[i])-97] = i;
            return i;
        }
    return T.length();
}

int main()
{
    string T;
    cin >> T;
    int match = 0;

    for(int i = 0; i < T.length()/2 + T.length() % 2; i++){
        if(T[i] == T[T.length()-1-i]) match++;
        else break;
    }

    if (match * 2 >= T.length()) cout << 1;
    else {
        bool matched[T.length()] = {};
        int index[26] = {};

        for(int i = 0; i < match; i++) {
            matched[i] = true;
            matched[T.length()-1-i] = true;
        }

        int left = T.length() - 1;
        for(int i = match; i < T.length() - match; i++) if(!matched[i]) left = min(findMatch(T, matched, i, match, index), left);
        cout << T.length() - left - match;
    }
}