#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
char s[maxn];
int n;
int main() {
  scanf("%s", s);
  n = strlen(s);
  int beg = 1;
  for (beg; beg < n; beg++) {
    if (s[beg] == s[beg - 1]) {
      beg--;
      break;
    }
  }
  int fron;
  if (beg >= n)
    fron = n;
  else
    fron = beg + 1;
  int L = n - 1, T = 0, ans = fron;
  for (int i = n - 2; i > beg; i--) {
    if (s[i] == s[i + 1]) {
      if (s[L] != s[T]) {
        fron = fron + L - i;
      } else {
        fron = L - i;
      }
      ans = max(ans, fron);
      L = i;
      T = i + 1;
    }
  }
  if (s[L] != s[T]) {
    fron = fron + L - beg;
  } else
    fron = L - beg;
  ans = max(ans, fron);
  printf("%d\n", ans);
  return 0;
}
