#include <bits/stdc++.h>
int main() {
  int f = 0, s = 0;
  char a[1000];
  scanf("%s", a);
  for (int i = 0; a[i] != '\0'; i++) {
    if (a[i] != a[i + 1]) {
      f++;
      s = 0;
    } else {
      s++;
      if (s == 5) {
        f++;
        s = 0;
      }
    }
  }
  printf("%d\n", f);
}
