#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 1) {
      cout << 1;
      return 0;
    }
    int cnt = 0, c1 = 1, cc = 1, chc = 1;
    for (int i = n - 2; i >= 0; i--) {
      if (s[i] != s[i + 1])
        c1++;
      else
        break;
    }
    if (c1 == n) {
      cout << n;
      return 0;
    }
    cnt = c1;
    for (int i = 1; i < n; i++) {
      if (s[i] != s[i - 1])
        cc++;
      else {
        cnt = max(cc, cnt);
        if (s[n - 1] == s[0])
          cnt = max(cc, c1);
        else {
          cnt = max(cnt, cc + c1);
        }
        break;
      }
    }
    for (int i = 1; i < n;) {
      int j = i;
      while (j < n && s[j] != s[j - 1]) {
        j++;
        chc++;
      }
      cnt = max(chc, cnt);
      chc = 1;
      i = j + 1;
    }
    cnt = max(chc, cnt);
    cout << cnt << endl;
  }
}
