#include <bits/stdc++.h>
using namespace std;
string S;
int Len;
int main(void) {
  register int i;
  cin >> S;
  Len = S.size();
  register int Ans;
  Ans = 0;
  for (i = 0; i < Len; i++) {
    if (S[i] != S[(i + 1) % Len]) {
      if (S[i] != S[(i + 2) % Len]) {
        Ans++;
      } else {
        if (S[i] != S[(i + 3) % Len]) {
          Ans++;
          i++;
        }
      }
    }
  }
  cout << Ans << endl;
  return 0;
}
