#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  int ans = 1, cnt = 1;
  for (int i = 1; s[i]; i++) {
    if (s[i] == s[i - 1] && cnt < 5)
      cnt++;
    else {
      cnt = 1;
      ans++;
    }
  }
  cout << ans;
  return 0;
}
