#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  string str;
  cin >> str;
  char g = str[0];
  long count = 0, d = 1;
  for (string::iterator i = str.begin() + 1; i < str.end(); ++i) {
    if (*i != g) {
      count++;
      g = *i;
      d = 1;
    } else if (d == 5) {
      count++;
      d = 1;
    } else {
      d++;
    }
  }
  cout << ++count;
  return 0;
}
