#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
map<char,ll> m1,m2;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    int itr1=-1,itr2=-1;
    for(int i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[s.size()-1-i])
        {
            itr1=i;
            itr2=s.size()-1-i;
            break;
        }
    }
    if(itr1==-1 && itr2==-1) cout<<1;
    else
    {
        for(int i=itr1;i<=itr2;i++)
        {
            m1[s[i]]++;
            m2[s[i]]++;
        }
        int br1=0,br2=0;
        for(int i=itr1;i<=itr2;i++)
        {
            if(m1[s[i]]>0)
            {
                if(m1[s[i]]==1)
                {
                    if(i!=s.size()/2)
                    {
                        br1=itr2-i+1;
                        break;
                    }
                }
                m1[s[i]]-=2;
            }
            else
            {
                br1=itr2-i+1;
                break;
            }
        }
        for(int i=itr2;i>=itr1;i--)
        {
            if(m2[s[i]]>0)
            {
                if(m2[s[i]]==1)
                {
                    if(i!=s.size()/2)
                    {
                        br2=i-itr1+1;
                        break;
                    }
                }
                m2[s[i]]-=2;
            }
            else
            {
                br2=i-itr1+1;
                break;
            }
        }
        cout<<min(br1,br2);
    }
    return 0;
}