#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 10;
string second;
int ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> second;
  int cur = 1;
  for (int i = 1; i < second.size(); i++) {
    if (second[i] != second[i - 1]) {
      cur++;
    } else {
      ans = max(ans, cur);
      cur = 1;
    }
  }
  ans = max(ans, cur);
  if (second[0] != second[second.size() - 1]) {
    int len1, len2;
    for (int i = 1; i < second.size(); i++) {
      if (second[i] == second[i - 1]) {
        len1 = i;
        break;
      }
    }
    for (int i = second.size() - 2; i >= 0; i--) {
      if (second[i] == second[i + 1]) {
        len2 = second.size() - i - 1;
        break;
      }
    }
    ans = max(ans, min(len1 + len2, (int)second.size()));
  }
  cout << ans;
  return 0;
}
