#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 1, mx = 0;
  string a;
  cin >> a;
  n = a.size();
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1])
      c++;
    else {
      mx = max(mx, c);
      c = 1;
    }
  }
  mx = max(mx, c);
  if (a[0] != a[n - 1]) {
    c = 2;
    for (int i = 1; i < n; i++) {
      if (a[i] != a[i - 1])
        c++;
      else
        break;
    }
    for (int i = n - 2; i >= 0; i--) {
      if (a[i] != a[i + 1])
        c++;
      else
        break;
    }
    c = min(n, c);
    mx = max(c, mx);
  }
  cout << mx << endl;
  return 0;
}
