#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int x = 0, p = 0;
  getline(cin, s);
  for (int i = 0; i < s.length(); i++) {
    float x = 0;
    if (s[i] == 'C') {
      while (s[i] == 'C') {
        x++;
        i++;
      }
    } else {
      while (s[i] == 'P') {
        x++;
        i++;
      }
    }
    i--;
    p = p + (ceil)(x / 5);
  }
  cout << p;
  return 0;
}
