#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
string s;
int main() {
  cin >> s;
  int ans = 0, cur = 0;
  for (int i = 0; i < ((int)(s).size()); i++) {
    if (i > 0 && s[i - 1] != s[i]) cur = 0;
    cur++;
    if (i + 1 == ((int)(s).size()) || s[i + 1] != s[i]) ans += (cur + 4) / 5;
  }
  printf("%d\n", ans);
  return 0;
}
