#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  string str;
  cin >> str;
  int counter = 0;
  int c = 0;
  for (i = 0; i < str.size(); i++) {
    if (c == 4 || i == 0 || str[i] != str[i - 1]) {
      counter++;
      c = 0;
    } else
      c++;
  }
  cout << counter << endl;
  return 0;
}
