#include <bits/stdc++.h>
using namespace std;
void solutionA();
int main() {
  ios_base::sync_with_stdio(false);
  solutionA();
  return EXIT_SUCCESS;
}
string s;
void solve() {
  long long ans = 0, len = 1;
  for (long long i = 1; i < (long long)s.size(); ++i) {
    if (s[i] != s[i - 1])
      len = 1, ++ans;
    else {
      ++len;
      if (len > 5) len = 1, ++ans;
    }
  }
  ++ans;
  cout << ans << endl;
}
void solutionA() {
  for (; cin >> s;) {
    solve();
    cerr << endl;
  }
}
