#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length(), count = 1, num = 0, flag = 0;
  char curr;
  if (n == 1)
    cout << "1";
  else {
    int i = 1;
    curr = s[0];
    while (i < n) {
      if (s[i] == curr) {
        count++;
        flag = 0;
        if (count == 5) {
          num++;
          count = 0;
          if (i < n - 1) curr = s[i + 1];
          flag = 1;
        }
      } else {
        num++;
        curr = s[i];
        count = 1;
        flag = 0;
      }
      i++;
    }
    if (!flag) num = num + 1;
    cout << num;
  }
  return 0;
}
