#include <bits/stdc++.h>
using namespace std;
char str[105];
int main() {
  scanf("%s", str);
  int count = 1;
  int i;
  int ac = 1;
  for (i = 1; str[i]; i++) {
    if (str[i] == str[i - 1]) ac++;
    if (ac > 5 || str[i] != str[i - 1]) {
      ac = 1;
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}
