#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  string s;
  int d = 0, x = 0;
  vector<int> v;
  cin >> s;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == s[i + 1])
      d++;
    else {
      v.push_back(d + 1);
      d = 0;
    }
  }
  if (s.length() >= 2) {
    if (d || (s[s.length() - 2] != s[s.length() - 1])) v.push_back(d + 1);
    for (int i = 0; i < v.size(); i++) {
      x = x + ceil((1.0 * v[i]) / 5);
    }
    cout << x;
  } else
    cout << 1;
}
