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