#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  int num = s.size();
  if (num == 2) {
    cout << 1 << endl;
    return 0;
  }
  s += s;
  for (int i = 0; i < num; i++) {
    if (s[i] != s[i + 1]) {
      if (s[i] != s[i + 2])
        ans++;
      else if (s[i] != s[i + 3])
        ans++, i++;
    }
  }
  cout << ans << endl;
  return 0;
}
