#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  char data[100];
  int num = 0;
  while (cin >> data[num++])
    ;
  num--;
  int i = 0, length = 1, sum = 0;
  while (i < num - 1) {
    if (data[i] == data[i + 1]) {
      length++;
      i++;
    } else {
      sum += (length / 5 + 1);
      if (length % 5 == 0) sum--;
      i++;
      length = 1;
    }
  }
  sum += (length / 5 + 1);
  if (length % 5 == 0) sum--;
  cout << sum;
  return 0;
}
