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