#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int c = 0, k = 5, l;
  cin >> s;
  l = s.length();
  for (int i = 0; i < l; i++) {
    k--;
    if (k == 0) {
      c++;
      k = 5;
    } else if (s[i + 1] != s[i] && i <= l - 1) {
      c++;
      k = 5;
    }
  }
  cout << c << endl;
  return 0;
}
