#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 5;
int dp1[N];
int main() {
  string s;
  cin >> s;
  dp1[0] = 1;
  int ans = 1;
  for (int i = 1; i < s.length(); i++) {
    if (s[i] != s[i - 1]) {
      dp1[i] = dp1[i - 1] + 1;
    } else {
      dp1[i] = 1;
    }
    ans = max(ans, dp1[i]);
  }
  if (s[0] != s.back()) {
    int i = 1;
    int j = (int)s.length() - 2;
    int len = 1;
    while (i <= j) {
      if (s[i] != s[i - 1]) {
        i++;
        len++;
      } else {
        break;
      }
    }
    int len2 = 1;
    while (j >= i) {
      if (s[j] != s[j + 1]) {
        j--;
        len2++;
      } else {
        break;
      }
    }
    len += len2;
    ans = max(ans, len);
  }
  cout << ans << endl;
}
