#include <bits/stdc++.h>
const int inf = (int)1e9 + 10;
using namespace std;
char x[1000010], s[1000010];
int f[1000010][3], ans;
int main() {
  scanf("%s", x + 1);
  int n = strlen(x + 1);
  int t = 0;
  x[0] = x[n], x[n + 1] = x[1];
  for (int i = 1; i <= n; ++i)
    if (x[i] != x[i - 1]) t = i;
  if (!t) {
    printf("1");
    exit(0);
  }
  for (int i = 1; i <= n; ++i) s[i] = x[(t + i - 2) % n + 1];
  f[1][1] = f[1][2] = -inf;
  f[1][0] = 0;
  for (int i = 2; i <= n; ++i) {
    if (s[i] == '0') {
      f[i][0] = max(f[i - 1][2], f[i - 1][0]);
      f[i][1] = max(f[i - 1][0] + 1, f[i][1]);
      f[i][2] = -inf;
    } else {
      f[i][0] = max(f[i - 1][1], f[i - 1][0]);
      f[i][2] = max(f[i - 1][0] + 1, f[i][2]);
      f[i][1] = -inf;
    }
  }
  ans = max(max(f[n][0], f[n][1]), f[n][2]);
  f[1][0] = f[1][2] = f[1][1] = -inf;
  if (s[1] == '0')
    f[1][1] = 1;
  else
    f[1][2] = 1;
  for (int i = 2; i <= n; ++i) {
    if (s[i] == '0') {
      f[i][0] = max(f[i - 1][2], f[i - 1][0]);
      f[i][1] = max(f[i - 1][0] + 1, f[i][1]);
      f[i][2] = -inf;
    } else {
      f[i][0] = max(f[i - 1][1], f[i - 1][0]);
      f[i][2] = max(f[i - 1][0] + 1, f[i][2]);
      f[i][1] = -inf;
    }
  }
  if (s[n] == '0') ans = max(ans, max(f[n][0], f[n][2]));
  if (s[n] == '1') ans = max(ans, max(f[n][0], f[n][1]));
  printf("%d", ans);
}
