#include <bits/stdc++.h>
using namespace std;
int cnt[1000005];
char s[1000005];
int main() {
  int i, j, len;
  int num = 0;
  scanf("%s", s);
  len = strlen(s);
  for (i = 0; i < len; i++) {
    num++;
    for (j = i; j < len; j++) {
      cnt[num]++;
      if (s[j] != s[j + 1]) break;
    }
    i = j;
  }
  if (s[len - 1] == s[0]) {
    cnt[1] += cnt[num];
    num--;
  }
  i = 1;
  int ans = 0;
  while (i <= num) {
    if (i == num && cnt[i] == 1) break;
    ans++;
    if (cnt[i] > 1)
      i++;
    else
      i += 2;
  }
  printf("%d\n", ans);
  return 0;
}
