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