#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll br[30];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    for (ll i=0;i<s.size();i++)
        br[s[i]-'a']++;
    ll l=0,r=s.size()-1,res=1;
    while (l<=r)
    {
        if (s[l]==s[r])
        {
            br[s[l]-'a']-=2;
            l++;
            r--;
            continue;
        }
        if (br[s[l]-'a']-1>0)
        {
            res=r-l;
            break;
        }
        if (br[s[r]-'a']-1>0)
        {
            res=r-l;
            break;
        }
        res=r-l+1;
        break;
    }
    cout << res << "\n";
    return 0;
}