#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string str;
  cin >> str;
  char lv = str[0];
  int cnt1 = 1, ans = 0;
  for (int i = 1; i < str.length(); i++) {
    if (str[i] == lv)
      cnt1++;
    else {
      cnt1 = 1;
      lv = str[i];
      ans++;
    }
    if (cnt1 == 5) {
      ans++;
      cnt1 = 0;
      if (i == (str.length() - 1))
        break;
      else
        lv = str[i + 1];
    }
  }
  if (cnt1) ans++;
  cout << ans << endl;
  return 0;
}
