#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 30;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int pref = 0, suf = n - 1;
  while (pref < n - 1 && s[pref] != s[pref + 1]) pref++;
  while (suf > 0 && s[suf] != s[suf - 1]) suf--;
  int ans = min(n, (s[n - 1] != s[0] ? pref + 1 + (n - suf) : 0));
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n - 1 && s[j] != s[j + 1]) j++;
    ans = max(ans, j - i + 1);
    i = j;
  }
  cout << ans;
  return 0;
}
