#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, x, k, p = 0, q = 0;
  string s;
  vector<long long> v;
  cin >> s;
  n = s.length();
  for (i = 0; i < n; i++) {
    k = 0;
    if (s[i] == 'C') {
      for (j = i; j < n; j++) {
        if (k == 5) break;
        if (s[j] == 'C') k++;
        if (s[j] == 'P') break;
      }
      p++;
    } else if (s[i] == 'P') {
      for (j = i; j < n; j++) {
        if (k == 5) break;
        if (s[j] == 'P') k++;
        if (s[j] == 'C') break;
      }
      p++;
    }
    i = j - 1;
  }
  cout << p << endl;
}
