#include <bits/stdc++.h>
using namespace std;
int main() {
  string data, time = "";
  cin >> data;
  int sch = 0;
  int result_ = 0;
  for (int i = 0; i < data.size(); i++) {
    if (i != 0 && data[i] == data[i - 1]) {
      sch++;
      if (sch == 5) {
        result_++;
        sch = 0;
      }
    } else {
      result_++;
      sch = 0;
    }
  }
  cout << result_;
}
