#include <bits/stdc++.h>
using namespace std;
char s[2000000];
int n;
int dp() {
  int st = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[(i + 1) % n]) {
      st = i;
    }
  }
  if (st == -1) return n / 2;
  int ans = 1;
  char prv = s[(st + 1) % n];
  int i;
  for (i = (st + 2) % n; i != st && i != (st + 1) % n; i = (i + 1) % n) {
    if (s[i] != prv) {
      ans++;
      prv = s[(i + 1) % n];
      i = (i + 1) % n;
    }
  }
  if (i != st)
    ans--;
  else if (s[st] == prv)
    ans--;
  return ans;
}
int main() {
  cin >> s;
  n = strlen(s);
  cout << dp() << '\n';
  return 0;
}
