#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int MAX = 1000;
const int inf = 999999999;
const int p1 = 104393321, p2 = 104393329;
int main() {
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  int cnt = 0, sum = 0;
  char c = s[0];
  for (int i = (1); i < int(s.size()); ++i) {
    if (s[i] != c) {
      sum++;
      c = s[i];
      cnt = 0;
    } else
      cnt++;
    if (cnt == 5) {
      sum++;
      cnt = 0;
    }
  }
  sum++;
  cout << sum << endl;
  return 0;
}
