#include <bits/stdc++.h>
using namespace std;
int main() {
  char ins[101];
  scanf("%s", ins);
  int repeateC = 0, closet = 0, repeateP = 0;
  for (int i = 0; i < strlen(ins); i++) {
    if (ins[i] == 'C') {
      if (repeateP > 0) {
        closet += repeateP / 5;
        if (repeateP % 5 != 0) closet += 1;
      }
      repeateC++;
      repeateP = 0;
    } else {
      if (repeateC > 0) {
        closet += repeateC / 5;
        if (repeateC % 5 != 0) closet += 1;
      }
      repeateC = 0;
      repeateP++;
    }
  }
  if (repeateP > 0) {
    closet += repeateP / 5;
    if (repeateP % 5 != 0) closet += 1;
  }
  if (repeateC > 0) {
    closet += repeateC / 5;
    if (repeateC % 5 != 0) closet += 1;
  }
  printf("%d\n", closet);
  return 0;
}
