#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
char str[maxn];
bool use[maxn];
int main() {
  scanf("%s", str);
  int n = strlen(str), i, chainlen, revlen, ans = 0;
  for (i = 0; i < n; ++i)
    if (str[i] == str[(i + 1) % n]) break;
  int st = i, step = 0;
  for (i = st, chainlen = 1; step < n; i = (i + 1) % n, ++step) {
    if (str[i] == str[(i + 1) % n]) {
      use[i] = use[(i + 1) % n] = use[(i + 2) % n] = 1;
      chainlen++;
    } else {
      if (chainlen > 1) ans++;
      chainlen = 1;
    }
  }
  for (i = 0; i < n; ++i)
    if (use[i]) break;
  int a = i;
  for (revlen = 0; i < n; ++i) {
    if (!use[i])
      revlen++;
    else {
      ans += (revlen + 1) / 2;
      revlen = 0;
    }
  }
  ans += (revlen + a + 1) / 2;
  printf("%d\n", ans);
  return 0;
}
