#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch[102], pre = 's', now;
  cin >> ch;
  int l = strlen(ch), i, j = 0, cnt = 0;
  for (i = 0; i < l; i++) {
    now = ch[i];
    if (now != pre || j == 5) {
      cnt++;
      j = 1;
    } else {
      j++;
    }
    pre = now;
  }
  cout << cnt;
  return 0;
}
