#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 3;
long long n, k, p, x, y, ans, mod, sum, a[N];
string f, s;
int main() {
  cin >> s;
  n = s.length();
  for (int i = 0; i < n;) {
    int j = 0;
    while (s[i] == s[i + j] && i + j < n) j++;
    ans += (j + 4) / 5;
    i += j;
  }
  cout << ans << endl;
  return 0;
}
