#include <bits/stdc++.h>
using namespace std;
int l[1000050], r[1000050], n;
char s[1000050];
void solve() {
  n = strlen(s);
  for (int i = 0; i <= n - 1; i++) {
    if (s[i] == '1') {
      r[i] = 1;
      l[(i + 1) % n] = 0;
    } else {
      r[i] = 0;
      l[(i + 1) % n] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i <= n - 1; i++) {
    if (l[i] != 2 && l[i] == r[i]) {
      cnt++;
      if (i - 1 < 0) {
        r[n - 1] = 2;
      } else
        r[i - 1] = 2;
      l[(i + 1) % n] = 2;
    }
  }
  printf("%d\n", cnt);
}
int main() {
  while (~scanf("%s", s)) {
    solve();
  }
  return 0;
}
