#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0, cnt2 = 0;
  for (int k = 0; k < s.size(); k++) {
    if (s[k] != s[k + 1]) {
      cnt++;
      cnt2 = 0;
    } else {
      cnt2++;
    }
    if (cnt2 == 5) {
      cnt++;
      cnt2 = 0;
    }
  }
  cout << cnt;
}
