#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int ans = 0;
char s[N];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  if (n <= 2) {
    puts("1");
    return 0;
  }
  for (int i = 1; i <= n; i++) s[i + n] = s[i];
  for (int i = 1; i <= n; i++)
    if (s[i] ^ s[i + 1]) {
      if (s[i] ^ s[i + 2])
        ans++;
      else if (s[i] ^ s[i + 3])
        ans++, i++;
    }
  printf("%d", ans);
}
