#include <bits/stdc++.h>
using namespace std;
char s[2000005];
int n, ok, last, a[2000006], col[2000006], st, tot;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) a[i] = s[i] - '0';
  for (int i = 1; i <= n; i++) a[n + i] = a[i];
  for (int i = 1; i <= n; i++) {
    int pre = i - 1;
    if (pre == 0) pre = n;
    if (!(a[i] ^ a[pre])) {
      st = i;
      break;
    }
  }
  if (!st) {
    printf("%d\n", n / 2);
    return 0;
  }
  for (int i = st; i <= st + n - 2;) {
    int now = i;
    last = i;
    tot++;
    while (a[i] == a[now] && i <= st + n) i++;
    i++;
    if (i == now + 1) i++;
  }
  for (int i = last; i != st; i = i >= n ? 1 : i + 1) {
    if (a[i] != a[last]) {
      ok = 1;
      break;
    }
  }
  if (!ok) tot--;
  if (tot == 0) tot++;
  printf("%d\n", tot);
  return 0;
}
