#include <bits/stdc++.h>
char s[128], a, *p;
int main() {
  gets(s);
  for (p = s; *p; ++p) {
    a++;
    for (int x = 4; x && *(p + 1) == *p; ++p, --x)
      ;
  }
  printf("%d\n", a);
  return 0;
}
