#include <bits/stdc++.h>
using namespace std;
char s[1000010];
bool f[1000010];
int main() {
  int i, l, ans = 0, ans2 = 0, j, sta;
  scanf("%s", &s);
  l = strlen(s);
  sta = 0;
  while (s[sta] == s[(sta + 1) % l]) {
    sta = (sta + 1) % l;
  }
  ++sta;
  memset(f, false, sizeof(bool) * l);
  i = sta;
  while (!f[i]) {
    f[i] = true;
    i = (i + l - 1) % l;
    while (s[(i + l - 1) % l] == s[i]) {
      f[i] = true;
      i = (i + l - 1) % l;
    }
    f[i] = true;
    i = (i + l - 1) % l;
    ++ans;
  }
  memset(f, false, sizeof(bool) * l);
  i = sta;
  while (!f[i]) {
    f[i] = true;
    while (s[(i + 1) % l] == s[i]) {
      i = (i + 1) % l;
      f[i] = true;
    }
    f[(i + 1) % l] = true;
    i = (i + 2) % l;
    ++ans2;
  }
  printf("%d\n", ans < ans2 ? ans : ans2);
  return 0;
}
