#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
char s[3000005];
int n;
int ans = 1;
bool vis[1000005];
void check(int t) {
  int res = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = t; i < t + n; ++i) {
    ++res;
    int j = i;
    vis[i % n] = 1;
    if (s[i] == '0') {
      while (s[j] == s[i]) {
        if (vis[(j + 1) % n]) --res;
        ++j;
      }
    } else {
      while (s[j] == s[i]) {
        if (vis[(j + 1) % n]) --res;
        ++j;
      }
    }
    i = j;
  }
  ans = max(ans, res);
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; ++i) s[i + n] = s[i + n + n] = s[i];
  check(0);
  check(1);
  check(2);
  cout << ans << endl;
  return 0;
}
