#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  cin >> input;
  int numofitems = 0, minimum = 0, size = input.size();
  if (size == 1) {
    minimum += 1;
  } else {
    for (int i = 0, j = i + 1; i < size - 1 && j < size; i++, j++) {
      if (input[i] == input[j] && numofitems < 5) {
        numofitems += 1;
      } else if (input[i] != input[j]) {
        if (numofitems != 0) {
          numofitems = 0;
        }
        minimum += 1;
      }
      if (numofitems == 5) {
        minimum += 1;
        numofitems = 0;
      }
      if (j == input.size() - 1 && numofitems > 0 && numofitems < 5) {
        minimum += 1;
      } else if (j == input.size() - 1)
        minimum += 1;
    }
  }
  cout << minimum << endl;
}
