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