#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  string str;
  cin >> str;
  char prev;
  int cnt = 1, no = 1;
  prev = str[0];
  for (int i = 1; i < str.length(); i++) {
    if (str[i] != prev || cnt + 1 > 5) {
      no++;
      cnt = 1;
      prev = str[i];
    } else
      cnt++;
  }
  cout << no;
}
