#include <bits/stdc++.h>
using namespace std;
const double eps = 1E-3;
const int pinf = 1E+9;
const int minf = 1E-9;
int main(int argc, char **argv) {
  string str;
  bool c = 0, p = 0;
  int count = 0;
  int ic = 0, ip = 0;
  cin >> str;
  for (string::iterator i = str.begin(); i != str.end(); ++i) {
    if (*i == 'C') {
      if (!p && ic < 4) {
        ++ic;
        c = true;
      } else if (ic >= 4) {
        ++count;
        ic = 0;
        p = c = false;
      } else {
        p = false;
        ++count;
        ip = 0;
        ic = 1;
        c = true;
      }
    } else if (!c && ip < 4) {
      ++ip;
      p = true;
    } else if (ip >= 4) {
      ++count;
      ip = 0;
      p = c = false;
    } else {
      c = false;
      ++count;
      ip = 1;
      ic = 0;
      p = true;
    }
  }
  cout << (ic > 0 || ip > 0 ? count + 1 : count);
  return 0;
}
