#include <bits/stdc++.h>
char s[1000001];
int c[1000000];
int main() {
  int i;
  int start;
  int len;
  int n = -1;
  int res;
  int flag;
  scanf("%s", &s);
  for (len = 0; s[len] != '\0'; len++)
    ;
  for (start = 0; s[start] == s[0]; start++)
    ;
  for (i = start; i < len + start; i++) {
    if (s[i % len] != s[(i - 1) % len]) {
      n++;
      c[n] = 1;
    } else
      c[n]++;
  }
  n++;
  for (start = 0; start <= n && c[start] == 1; start++)
    ;
  res = 0;
  flag = 0;
  for (i = start; i < n + start; i++) {
    if (c[i % n] > 1) {
      res++;
      flag = 0;
    } else if (flag == 1) {
      res++;
      flag = 0;
    } else
      flag = 1;
  }
  printf("%d\n", res);
  return 0;
}
