#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  int ret = 0;
  int acc = 0;
  int prev = -1;
  for (int i = 0; i < (int)(n); i++) {
    if (s[i] == prev) {
      ++acc;
    } else {
      acc = 1;
      prev = s[i];
    }
    if (i == n - 1 || s[i + 1] != s[i] || acc >= 5) {
      acc = 0;
      ++ret;
    }
  }
  cout << ret << endl;
  return 0;
}
