#include <bits/stdc++.h>
using namespace std;
char ins[102], c;
int ans, cnt;
int main() {
  gets(ins);
  int l = strlen(ins);
  for (int i = 0; i < l;) {
    ans++;
    cnt = 0;
    c = ins[i];
    while (i < l && ins[i] == c && cnt < 5) cnt++, i++;
  }
  printf("%d\n", ans);
  return 0;
}
