#include <bits/stdc++.h>
#define MAXN 100010
#define pb push_back
#define ll long long
#define fi first
#define se second
#define mp make_pair

using namespace std;

int ccount[26];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	string s;
	cin >> s;
	int sp = 0, n = s.size();
	while (s[sp] == s[sp] && sp < (n-1) / 2)
        sp++;
    if (sp >= (n-1) / 2)
    {
        cout << 1;
        return 0;
    }
    int res = INT_MAX;
    int maks = 0;
    for (int i = sp; i <= n/2; i++)
    {
        int j;
        for (j = n - sp - 1; s[j] != s[i]; j--)
            ;
        maks = max(maks, n - sp  - 1 - j);
    }
    res = maks;
    for (int i = n-sp-1; i >= n/2; i--)
    {
        int j;
        for (j = sp; s[j] != s[i]; j++)
            ;
        maks = max(maks, j - sp);
    }
    res = min(maks, res);
    cout << res;
	return 0;
}