#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0, t = 1, ans = 0;
  char flag = s[0];
  for (int i = 0; i < s.length(); i++) {
    if (flag == s[i])
      cnt++;
    else
      cnt = 1, ans++, flag = s[i];
    if (cnt == 5) cnt = 0, ans++, flag = s[i + 1];
  }
  ans += (cnt > 0);
  cout << ans;
  return 0;
}
