#include <bits/stdc++.h>
using namespace std;
int main() {
  srand((unsigned int)time(NULL));
  string second;
  cin >> second;
  second.push_back(second[0]);
  second.push_back(second[1]);
  second.push_back(second[2]);
  int ret = 0;
  for (int i = 0; i < second.size() - 3; i++) {
    if (second[i] != second[i + 1] && second[i] != second[i + 2]) ret++;
  }
  for (int i = 0; i < second.size() - 3; i++) {
    if (second[i] != second[i + 1] && second[i] == second[i + 2] &&
        second[i + 3] != second[i]) {
      ret++;
      i++;
    }
  }
  cout << ret << endl;
}
