#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); string S; cin >> S; auto f = [](string s) { int res = 0; for (int i = 0; i < (int)s.size(); i++) { if (s[0] != s[i]) break; res++; } return res; }; int res = f(S); reverse(S.begin(), S.end()); cout << min(res - 1, f(S)) << '\n'; return 0; }