#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  char cur;
  int beg = 1, end, mid = 0;
  int i, j;
  cin >> s;
  n = s.length();
  end = n - 2;
  cur = s[0];
  while (beg < n && s[beg] != cur) cur = s[beg++];
  cur = s[n - 1];
  while (end >= 0 && s[end] != cur) cur = s[end--];
  end++;
  end = n - end;
  for (i = 0; i < n; i++) {
    int c = 1;
    cur = s[i];
    for (j = i + 1; j < n; j++) {
      if (s[j] != cur)
        cur = s[j], c++;
      else
        break;
    }
    i = j - 1;
    mid = max(mid, c);
  }
  if (s[0] != s[n - 1]) beg += end;
  cout << min(max(max(beg, end), mid), n) << endl;
  return 0;
}
