#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  string s;
  while (cin >> s) {
    int ln = s.length();
    int ct = 0;
    for (i = 0; i < ln; i = j) {
      for (j = i + 1; j < ln && s[i] == s[j]; ++j)
        ;
      ct += (j - i + 4) / 5;
    }
    cout << ct << endl;
  }
  return 0;
}
