#include <bits/stdc++.h>
using namespace std;
char str[1111111];
int val[1111111];
int main() {
  int res, p, N, u, i, j, n;
  scanf("%s", str);
  N = strlen(str);
  u = N - 1;
  while (u >= 0 && str[u] == str[0]) u--;
  u++;
  for (i = n = 0; i < N; i = j) {
    for (j = i; j < N; j++) {
      if (str[(u + i) % N] != str[(u + j) % N]) break;
    }
    val[n++] = j - i;
  }
  for (u = 0; u < n; u++)
    if (val[u] > 1) break;
  if (u == n) u = 0;
  res = 0;
  for (i = p = 0; i < n; i++) {
    p += val[(i + u) % n];
    if (p > 1) {
      res++;
      p = 0;
    } else {
      p = 1;
    }
  }
  printf("%d\n", res);
  return 0;
}
