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