#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1, M = 1e7, OO = 0x3f3f3f3f;
const long long int MOD = 2e9 + 7;
int main() {
  string s;
  cin >> s;
  double cnt = 0, ans = 0;
  for (int i = 0; i < int(s.size()); ++i) {
    if (s[i] == s[i + 1]) {
      cnt++;
    } else {
      cnt++;
      ans += ceil(cnt / 5.0);
      cnt = 0;
    }
  }
  cout << max(ans, cnt);
  return 0;
}
