#include <bits/stdc++.h>
char a[1000010];
int main() {
  while (scanf("%s", a) != EOF) {
    int i;
    int len = strlen(a);
    int ans = 0;
    int now = a[0];
    i = 0;
    while (a[i] == now) i++;
    int start = i;
    int p = (i + 1) % len;
    int chainlen = 0;
    int isselect = 0;
    int isFirstSelect = 0;
    int isFirst = 1;
    while (1) {
      if (a[p] != a[(p - 1 + len) % len]) {
        if (!isselect)
          chainlen++;
        else
          isselect = 0;
      } else {
        if (!isselect) {
          if (isFirst) {
            if ((chainlen - 1) % 2 == 0)
              isFirstSelect = 0;
            else
              isFirstSelect = 1;
            isFirst = 0;
          }
          isselect = 1;
          ans++;
          ans += chainlen / 2;
          chainlen = 0;
        }
      }
      p = (p + 1) % len;
      if (p == start) {
        if (!isFirstSelect && !isselect) chainlen++;
        ans += (chainlen + 1) / 2;
        break;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
