#include <bits/stdc++.h>
const int MAX_BUF_SIZE = 16384;
char BUFOR[MAX_BUF_SIZE];
int BUF_SIZE, BUF_POS;
char ZZZ;
using namespace std;
int n, m, k;
int wynik;
char slowo[2000007];
int check() {
  for (int i = 1; i < n; i++) {
    if (slowo[i] == slowo[i - 1]) return i;
  }
  return n % 2 == 0 ? -1 : 0;
}
int main() {
  scanf("%s", slowo);
  n = strlen(slowo);
  for (int i = 0; i < (n); i++) slowo[i + n] = slowo[i];
  int poz = check();
  if (poz == -1) {
    printf("%d\n", n / 2);
    return 0;
  }
  int wynik = 0;
  int kon = n + poz;
  int last = slowo[kon - 1];
  while (slowo[kon - 1] == last) kon--;
  kon--;
  for (int i = poz; i <= kon; i++) {
    wynik++;
    last = slowo[i];
    while (slowo[i] == last) i++;
  }
  cout << wynik << endl;
  return 0;
}
