#include <bits/stdc++.h>
using namespace std;
int n;
char s[1001000];
int main() {
  scanf("%s", s);
  n = strlen(s);
  int i;
  int count;
  int lst;
  vector<int> v;
  int ans = 0;
  for (i = 0; i < n; i++) s[i] -= '0';
  count = 0;
  for (i = 0;; i = ((i - 1 + n) % n)) {
    if (s[i] != s[((i - 1 + n) % n)]) break;
    count++;
  }
  lst = i;
  for (i = 0;; i = ((i + 1) % n)) {
    count++;
    if (s[i] != s[((i + 1) % n)]) break;
  }
  v.push_back(count);
  count = 0;
  for (i = ((i + 1) % n); i != lst; i = ((i + 1) % n)) {
    count++;
    if (s[i] != s[((i + 1) % n)]) {
      v.push_back(count);
      count = 0;
    }
  }
  int vn = v.size();
  for (i = 0; i < vn; i++) {
    if (v[i] != 1) break;
  }
  if (i == vn) {
    printf("%d\n", vn / 2);
    return 0;
  }
  count = 0;
  for (int j = 0; j < vn; j++) {
    if (v[(i + j) % vn] == 1) {
      count++;
    } else {
      ans += count / 2 + 1;
      count = 0;
    }
  }
  ans += count / 2;
  printf("%d\n", ans);
  return 0;
}
