#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, count = 1, ans = 0;
  string input;
  cin >> input;
  for (i = 1; i < input.length(); i++) {
    if (input[i] != input[i - 1]) {
      ans += (count / 5) + (count % 5 > 0);
      count = 0;
    }
    count++;
  }
  ans += (count / 5) + (count % 5 > 0);
  cout << ans << endl;
  return 0;
}
