#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec;
  string s;
  int c1 = 0, c2 = 0, total = 0;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'C' || s[i] == 'c') {
      c1++;
      if (c2 != 0) vec.push_back(c2);
      c2 = 0;
    }
    if (s[i] == 'P' || s[i] == 'p') {
      c2++;
      if (c1 != 0) vec.push_back(c1);
      c1 = 0;
    }
  }
  if (c1 != 0) vec.push_back(c1);
  if (c2 != 0) vec.push_back(c2);
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] <= 5) total++;
    if (vec[i] > 5) {
      if (vec[i] % 5 == 0) total += vec[i] / 5;
      if (vec[i] % 5 != 0) total += (vec[i] / 5) + 1;
    }
  }
  cout << total << endl;
  return 0;
}
