#include <bits/stdc++.h>
using namespace std;
int main() {
  string wall;
  cin >> wall;
  int ans, cnt;
  ans = cnt = 0;
  char current = wall[0];
  for (int i = 0; i < wall.size(); i++) {
    if (wall[i] != current) {
      ans++;
      cnt = 0;
      current = wall[i];
    } else if (cnt == 5) {
      cnt = 0;
      ans++;
    }
    cnt++;
  }
  cout << ans + 1 << endl;
  return 0;
}
