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