#include <bits/stdc++.h>
using namespace std;
int a[100001], b[100001], c, d, i, n, m, k, x = 1, y, z, g, j, t;
string s, s1, s2;
int main() {
  cin >> s;
  n = s.size();
  for (i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      t++;
      x = 1;
    }
    if (s[i] == s[i + 1]) x++;
    if (x == 5) {
      t++;
      x = 1;
      i++;
    }
  }
  i = n - 1;
  while (true) {
    if (s[i] == s[i - 1]) z++;
    if (s[i] != s[i - 1]) {
      z++;
      break;
    }
    i--;
  }
  if (z % 5 == 0)
    cout << t;
  else
    cout << t + 1;
}
