#include <iostream>

using namespace std;

int main()
{
    int n,a;
    string T;
    cin>>T;
    n=T.length();
    int k=n-1;
    for (int i=0;i<n/2;i++)
    {
        if(T[k]==T[i])
            a=n-i-i-3;
            break;
        k--;
    }

    cout << a << endl;
    return 0;
}