#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  string str;
  cin >> str;
  int counter = 0;
  int sub_count = 0;
  char last = '0';
  for (int i = 0; i < str.length(); i++) {
    if (sub_count <= 4) {
      if (str[i] == last || last == '0') {
        sub_count++;
        last = str[i];
      } else {
        sub_count = 1;
        counter++;
        last = str[i];
      }
    }
    if (sub_count > 4 || i == str.length() - 1) {
      sub_count = 0;
      counter++;
      last = '0';
    }
  }
  cout << counter << endl;
  return 0;
}
