#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, x, y;
  string a;
  cin >> a;
  n = a.size();
  char D[n];
  for (i = 0; i < n; i = i + 1) {
    D[i] = a.at(i);
  }
  x = 1;
  for (i = 0; i < n - 1; i = i + 1) {
    if (D[i] != D[i + 1]) {
      x = x + 1;
    }
  }
  y = 0;
  while (y < n - 5) {
    if (D[y] == D[y + 1] && D[y] == D[y + 2] && D[y] == D[y + 3] &&
        D[y] == D[y + 4] && D[y] == D[y + 5]) {
      x = x + 1;
      y = y + 5;
    } else {
      y = y + 1;
    }
  }
  cout << x;
  return 0;
}
