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