#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int count = 0, a = 1;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      a++;
      if (a == 5) {
        count++;
        a = 0;
      }
    } else {
      if (a > 0) count++;
      a = 1;
    }
  }
  cout << (a > 0 ? count + 1 : count);
}
