#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, pos2, res = 1, pos1;
string s;
int main() {
  cin >> s;
  n = s.length();
  s = ' ' + s;
  pos2 = n;
  for (int i = n - 1; i >= 1; i--)
    if (s[i] != s[i + 1])
      pos2--;
    else
      break;
  pos1 = 1;
  for (int i = 2; i <= n; i++)
    if (s[i] != s[i - 1])
      pos1++;
    else
      break;
  if (s[1] != s[n])
    if (pos1 < pos2)
      res = pos1 + n - pos2 + 1;
    else
      res = n;
  int tmp = 1;
  for (int i = 2; i <= n; i++) {
    if (s[i] != s[i - 1]) {
      tmp++;
      res = max(res, tmp);
    } else
      tmp = 1;
  }
  cout << res;
}
