#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int j = 0;
  int count = 1;
  while (S.at(S.size() - j - 1) == S.at(S.size() - j - 2)) {
    count++;
    j++;
    if (j == (S.size() - 1)) break;
  }
  int K = 1;
  for (int i = 0; i < (S.size() - 1); i++) {
    if (count > 4 && ((count - 5) % 3) == 0 && (S.size() - count) == i) {
      K += ((count / 5 - 1) * 2 + 3) - 1;
      break;
    }
    if (S.at(i) == S.at(i + 1)) {
      K++;
      i++;
    } else {
      K++;
    }
  }
  cout << K << endl;
}
