#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size(), count = 1, ans = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      count++;
    else {
      ans += count / 5;
      if (count % 5) ans++;
      count = 1;
    }
  }
  ans += count / 5;
  if (count % 5) ans++;
  cout << ans << endl;
}
