#include <bits/stdc++.h>
using namespace std;
int x = 0;
int ans = 0;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  char last = s[0];
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != last) {
      x = 1;
      ans++;
    } else if (x == 5) {
      x = 1;
      ans++;
    } else
      x++;
    last = s[i];
  }
  cout << ans + 1 << endl;
  return 0;
}
