#include <bits/stdc++.h>
using namespace std;
string i2s(int a) {
  string res = "";
  while (a > 0) {
    res += char(a % 10 + '0');
    a /= 10;
  }
  return res;
}
int s2i(string s) {
  int res = 0;
  int j = 1;
  for (int i = 0; i < s.length(); i++) {
    res += int(s[i] - '0') * j;
    j *= 10;
  }
  return res;
}
int main() {
  string s;
  cin >> s;
  s += "#";
  int a[100];
  int c = 1;
  int j = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] != s[i + 1]) {
      a[j] = c;
      c = 0;
      j++;
    }
    c++;
  }
  int res = 0;
  for (int i = 0; i < j; i++) {
    res += a[i] / 5;
    res += a[i] % 5 != 0 ? 1 : 0;
  }
  cout << res << endl;
  return 0;
}
