#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
using namespace std;

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

    int sz = str.size();
    bool isPalindrome = true;
    for(int i = 0; i < sz/2; i++)
    {
        if(str[i] != str[sz-i-1])
        {
            isPalindrome = false;
            break;
        }
    }

    if(isPalindrome)
    {
        cout << 1;
    } else {
        int cnt[26] = {0};

        for(int i = 0; i < sz; i++)
        {
            cnt[(int(str[i]) % 97)]++;
        }

        int startPos;
        int left[26] = {0};
        int ending = sz;
        bool dec = true;
        for(int i = 0; i < sz; i++)
        {
            if(str[i]==str[sz-i-1] && dec)
            {
                ending--;
            } else dec=false;

            if(cnt[(int(str[i]) % 97)] > left[(int(str[i]) % 97)] && cnt[(int(str[i]) % 97)] > 1)
            {
                cnt[(int(str[i]) % 97)]--;
                left[(int(str[i]) % 97)]++;

            } else {
                startPos = i;
                break;
            }
        }
        cout << abs(startPos-ending);
    }
}