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