#include <bits/stdc++.h>
using namespace std;
constexpr long long int MOD = 1000000007;
constexpr double EPS = 1e-8;
long long int N, M, K, H, W, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  while (!s.empty()) {
    int cnt = 0;
    char st = s.back();
    while (cnt < 5 && !s.empty() && s.back() == st) {
      s.pop_back();
      cnt++;
    }
    M++;
  }
  cout << M << endl;
}
