#include <bits/stdc++.h>
using namespace std;
char t[3000005];
int main() {
  scanf("%s", t);
  int n = strlen(t);
  int st = 0;
  for (; st < n; st++) {
    if (t[st] == t[n - 1]) {
      t[n++] = t[n - 1];
    } else
      break;
  }
  vector<int> v;
  int tmp = 1;
  for (int i = st + 1; i < n; i++) {
    if (t[i] != t[i - 1]) {
      v.push_back(tmp);
      tmp = 1;
    } else
      tmp++;
  }
  v.push_back(tmp);
  for (tmp = 0; tmp < v.size(); tmp++) {
    if (v[tmp] != 1) break;
  }
  if (tmp == v.size()) tmp--;
  vector<int> k;
  for (int i = tmp; i < v.size(); i++) k.push_back(v[i]);
  for (int i = 0; i < tmp; i++) k.push_back(v[i]);
  int tot = 0, ans = 0;
  for (int i = 0; i < k.size(); i++) {
    if (k[i] == 1) {
      tot++;
    } else {
      if (tot > 1) ans += tot / 2;
      ans++;
      tot = 0;
    }
  }
  ans += tot / 2;
  printf("%d\n", ans);
  return 0;
}
