#include <bits/stdc++.h>
char s[1000111];
int ans;
int i, j, k;
bool done[1000111];
int n;
int main() {
  scanf("%s", s);
  for (n = 0; s[n]; ++n)
    ;
  for (i = 0; i < n; ++i)
    if (!done[i] && s[(i - 1 + n) % n] == s[i]) {
      ++ans;
      for (j = i; !done[j]; j = (j + 1) % n) {
        done[j] = true;
        if (s[j] != s[i]) break;
      }
      done[i] = false;
      for (j = i; !done[j]; j = (j - 1 + n) % n) {
        done[j] = true;
        if (s[(j - 1 + n) % n] != s[(i - 1 + n) % n]) break;
      }
    }
  for (i = 0; i < n && done[i]; ++i)
    ;
  if (i < n) {
    if (ans) {
      for (i = 0; !done[i]; ++i)
        ;
      for (; done[i]; i = (i + 1) % n)
        ;
      k = (i - 1 + n) % n;
    } else
      k = n - 1;
    for (; i != k; i = (i + 1) % n)
      if (!done[i]) {
        ++ans;
        for (j = i; !done[j]; j = (j + 1) % n) {
          done[j] = true;
          if (s[j] != s[i]) break;
        }
        done[i] = false;
        for (j = i; !done[j]; j = (j - 1 + n) % n) {
          done[j] = true;
          if (s[(j - 1 + n) % n] != s[(i - 1 + n) % n]) break;
        }
      }
  }
  printf("%d\n", ans);
  return 0;
}
