#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int s[maxn], n, i, t, k, ans;
char a[maxn];
int main() {
  scanf("%s", a);
  for (i = 0; a[i]; i++)
    if (a[i] != a[i - 1])
      s[t++]++;
    else
      s[t - 1]++;
  if (a[i - 1] == a[0]) s[0] += s[--t];
  for (i = 0; i < t; i++)
    if (s[i] == 1)
      k++;
    else
      ans += k / 2 + 1, k = 0;
  printf("%d\n", ans + k / 2);
  return 0;
}
