#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int ans = 0, i = 0, cnt = 0;
  while (i < s.length()) {
    cnt = 0;
    while (s[i] == s[i + 1] && cnt < 5 && i < s.length()) {
      i++;
      cnt++;
    }
    if (cnt == 5) ans++;
    if (s[i] != s[i + 1]) {
      ans++;
      i++;
    }
    if (i == s.length() - 1 && s[i] == s[i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}
