#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int stk[maxn], top;
char a[maxn];
int main() {
  scanf("%s", a);
  int n = strlen(a);
  for (int i = 0; i < n; i++) {
    if (i == 0 || a[i] ^ a[i - 1])
      stk[++top] = 1;
    else
      stk[top] = 0;
  }
  if (a[0] == a[n - 1]) stk[1] = 0, --top;
  int ans = 0, res = 0;
  for (int i = 1; i <= top; i++) {
    if (stk[i])
      res++;
    else
      ans += res / 2 + 1, res = 0;
  }
  printf("%d\n", ans + res / 2);
  return 0;
}
