#include <bits/stdc++.h>
using namespace std;
int main() {
  int k = 1, n, m, a, i, j = 1;
  bool t = true;
  char c, h;
  cin >> c;
  while (cin >> h) {
    if (h == c)
      if (k != 5)
        k++;
      else {
        k = 1;
        j++;
      }
    else {
      k = 1;
      j++;
      c = h;
    }
  }
  cout << j;
  return 0;
}
