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