#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int j = 0;
  int count = 1;
  int K = 1;
  if (S.size() == 1) {
    K = 1;
  } else if (S.size() == 2 && S.at(0) == S.at(1)) {
    K = 1;
  } else {
    while (S.at(S.size() - j - 1) == S.at(S.size() - j - 2)) {
      count++;
      j++;
      if (j == (S.size() - 1)) break;
    }
    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;
}
