public void solve() throws IOException {
    String input = nextToken();

    int count = 0;
    char type = '0';
    int trips = 0;
    for (int x = 0; x < input.length(); x++) {
      if (count == 0) {
        type = input.charAt(x);
        count++;
      } else if (type == input.charAt(x)) {
        count++;
        if (count == 5) {
          count = 0;
          trips++;
          type = '0';
        }
      } else {
        trips++;
        count = 1;
        type = input.charAt(x);
      }
    }
    if (count != 0)
      trips++;

    System.out.println(trips);
  }