#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int len = str.size();
  int times = 0;
  int c = 0, p = 0;
  char tmp;
  for (int i = int(0); i <= int(len - 1); i++) {
    c = 0, p = 0;
    tmp = str[i];
    if (tmp == 'C') {
      while (str[i] == tmp && i < len) {
        c++;
        if (c > 5) {
          break;
        }
        i++;
      }
      i--;
      times++;
    }
    if (tmp == 'P') {
      while (str[i] == tmp && i < len) {
        p++;
        if (p > 5) {
          break;
        }
        i++;
      }
      i--;
      times++;
    }
  }
  cout << times << endl;
  return 0;
}
