#include <bits/stdc++.h>
using namespace std;
long long int powm(long long int base, long long int exp) {
  long long int ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % 1000000007;
    exp >>= 1, base = (base * base) % 1000000007;
  }
  return ans;
}
int main() {
  string second;
  cin >> second;
  int n = second.length();
  bool flag = true;
  int cnt = 1, ma = 1;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (second[i] != second[i - 1]) {
      cnt += 1;
      ma = max(ma, cnt);
    } else {
      cnt = 1;
    }
  }
  if (second[0] != second[n - 1]) {
    int start = 1, last = 1, bi = 0, li = n - 1;
    for (int i = 1; i < n; i++) {
      if (second[i] != second[i - 1]) {
        start += 1;
        bi = i;
      } else {
        break;
      }
    }
    for (int i = n - 2; i >= 0; i--) {
      if (second[i] != second[i + 1]) {
        last += 1;
        li = i;
      } else {
        break;
      }
    }
    if (li > bi) {
      ma = max(ma, start + last);
    }
  }
  cout << ma << endl;
}
