#include <bits/stdc++.h>
using namespace std;
int n, ans = 0, o;
char a[111];
int main() {
  gets(a);
  n = strlen(a);
  a[n] = 'o';
  for (int i = 0; i <= n; i++)
    if (i && a[i] != a[i - 1])
      ans += (o + 4) / 5, o = 1;
    else
      o++;
  cout << (ans) << endl;
  return 0;
}
