#include <bits/stdc++.h>
using namespace std;
int arr[1000009];
int main() {
  string s;
  cin >> s;
  int p = 1, t = 0;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      p++;
    } else if (s[i] != s[i - 1]) {
      p = 1;
      t++;
    }
    if (p > 5) {
      t++;
      p = 1;
    }
  }
  cout << t + 1 << endl;
  return 0;
}
