#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt, i, j, len = 0;
  string str;
  cin >> str;
  len = str.size();
  cnt = 0;
  for (i = 0; i < len;) {
    for (j = 1; j < 5; j++) {
      if (str[i] != str[i + j]) {
        break;
      }
    }
    cnt++;
    i += j;
  }
  cout << cnt << endl;
  return 0;
}
