#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[10000];
  scanf("%s", a);
  int l = strlen(a), i, k = 0, h = 0;
  for (i = 0; i < l - 1; i++) {
    if (a[i] == a[i + 1])
      h++;
    else
      k++, h = 0;
    if (h == 5) k++, h = 0;
  }
  printf("%d\n", k + 1);
  return 0;
}
