#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000 + 10;
const int INF = 10000000 + 10;
int n;
char str[MAX];
int f[MAX][2];
int calc(int a, int b) {
  f[0][0] = a;
  f[0][1] = b;
  int i;
  for (i = 1; i < n; ++i)
    if (str[i - 1] == str[i]) {
      f[i][1] = max(f[i - 1][1], f[i - 1][0] + 1);
      f[i][0] = f[i - 1][0];
    } else {
      f[i][1] = max(f[i - 1][1], f[i - 1][0] + 1);
      f[i][0] = max(f[i - 1][1], f[i - 1][0]);
    }
  return max(f[n - 1][1], f[n - 1][0]);
}
int main() {
  int i;
  scanf("%s", str);
  n = strlen(str);
  for (i = n - 1; i >= 0; --i)
    if (str[i] == '1' && str[(i + 1) % n] == '0') break;
  rotate(str, str + i + 1, str + n);
  int ans = 0;
  ans = max(ans, calc(0, -INF));
  while (str[n - 1] == '1') --n;
  ans = max(ans, calc(-INF, 1));
  printf("%d\n", ans);
  return 0;
}
