#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int n, dif[1000005] = {0, 1}, tp = 1, ans = 0, t = 0;
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      dif[tp] = 0;
    else
      dif[++tp] = 1;
  }
  if (s[0] == s[n - 1]) dif[1] = 0, --tp;
  for (int i = 1; i <= tp; i++) {
    if (dif[i])
      t++;
    else
      ans += 1 + t / 2, t = 0;
  }
  ans += t / 2;
  cout << ans;
  return 0;
}
