#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  char current = ' ';
  char prev = current;
  int count = 0;
  int five = 0;
  for (int i = 0; i < x.size(); i++) {
    current = x[i];
    if (five == 5) {
      count++;
      prev = current;
      five = 0;
    }
    if (current != prev) {
      count++;
      prev = current;
      five = 1;
    } else {
      five++;
      prev = current;
    }
  }
  cout << count;
  return 0;
}
