#include <bits/stdc++.h>
using namespace std;
int main() {
  int cl = 0, i = 0;
  string s;
  cin >> s;
  int l = s.size();
  while (i < l) {
    for (int j = 0; i < l - 1 && j < 4; j++) {
      if ((s[i + 1] == 'P' && s[i] == 'C') || (s[i + 1] == 'C' && s[i] == 'P'))
        break;
      i++;
    }
    i++;
    cl++;
  }
  cout << cl << endl;
  return 0;
}
