#include <bits/stdc++.h>
using namespace std;
char s[110];
int a, b, ans;
int main() {
  cin >> s;
  int l = strlen(s);
  if (s[0] == 'C')
    a++;
  else
    b++;
  for (int i = 1; i < l; i++) {
    if (s[i] == 'C') {
      if (b || a == 5) {
        ans++;
        b = 0;
        a = 1;
      } else
        a++;
    } else {
      if (a || b == 5) {
        ans++;
        a = 0;
        b = 1;
      } else
        b++;
    }
  }
  cout << ans + 1;
  return 0;
}
