#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char now = ' ';
  int count = 0, sum = 0, n;
  n = s.size();
  for (int i = 0; i < n; i++) {
    if (now == s[i] and count < 5)
      count++;
    else
      sum++, now = s[i], count = 1;
  }
  cout << sum << "\n";
  return 0;
}
