#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string str;
    cin >> str;
    int l = 0, d = str.size() - 1;
    while (str[l] == str[d]){
        l++; d--;
        if (l >= d){
            cout << 1;
            return 0;
        }
    }
    int l2 = l, d2 = d;
    int m = d - l;
    int m2 = m;
    l++; d2--;
    while (str[l2] != str[l]){
        l++;
        m2--;
        if (l >= d){
            m2 = INT_MAX;
            break;
        }
    }
    while (str[d2] != str[d]){
        d2--;
        m--;
        if (d2 < l2){
            m = INT_MAX;
            break;
        }
    }
    if (m < m2) cout << m;
    else cout << m2;
	return 0;
}