#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int prevcount = 0;
  int count = 1;
  char prevchar = S[0];
  for (int i = 1; i < S.length(); i++) {
    if (S[i] == prevchar) {
      count++;
    } else {
      ans += (count - (count + 1) / 3);
      if (prevcount % 3 == 2 && count % 3 == 2) {
        ans++;
        prevcount = 0;
      } else {
        prevcount = count;
      }
      count = 1;
    }
    prevchar = S[i];
  }
  ans += (count - (count + 1) / 3);
  if (prevcount % 3 == 2 && count % 3 == 2) {
    ans++;
    prevcount = 0;
  } else {
    prevcount = count;
  }
  cout << ans << endl;
  return 0;
}
