#include <bits/stdc++.h>
int main() {
  int steps, count, i, n;
  char str[500];
  char pc;
  scanf("%s", str);
  steps = count = 0;
  n = strlen(str);
  if (n == 0) {
    printf("0\n");
    return 0;
  }
  pc = str[0];
  count = 1;
  for (i = 1; i < n; i++) {
    if (count == 5) {
      count = 1;
      steps++;
      pc = str[i];
      continue;
    }
    if (pc == str[i])
      count++;
    else {
      count = 1;
      steps++;
      pc = str[i];
    }
  }
  if (count > 0) steps++;
  printf("%d\n", steps);
  return 0;
}
