#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  s += 'a';
  int l = s.length();
  int sum = 0;
  for (int i = 0; i < l - 1 && s[i] != 'a'; i++) {
    int t = 0, temp = 0;
    while (s[i] == s[i + 1] && t < 5 && i < l - 1) {
      t++;
      i++;
      temp = 1;
    }
    if (t == 5) i--;
    sum++;
  }
  cout << sum;
  return 0;
}
