#include <bits/stdc++.h>
int slova[27];
int NeresenaSlova;
int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string T;
    cin >> T;
    int i = 0 , j = T.length() - 1;
    int StartWith = -1, EndWith = -1, StartWithJ = -1;
    while(i < j)
    { 
        if(T[i] == T[j]){
            j--;
            if(NeresenaSlova > 0)
                EndWith = i;  
            while(slova[T[j] - 'a'] > 0)
            {
                slova[T[j]] --;
                j--;
                NeresenaSlova--;
        }}
        else
        { 
            if(StartWith == -1)
            { 
                StartWith = i;
                StartWithJ = j;
            }
            slova[T[i] - 'a'] ++;
            EndWith = i;
            NeresenaSlova++;         
        }
        i++;
    } 
    if(j == StartWithJ )
    {
        if(slova[T[StartWith]] > 1)
            StartWith++;
    }
    if(StartWith == -1)
        cout << 1;
    else 
        cout << EndWith - StartWith + 1;
    
    return 0;
}