#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  string s;
  cin >> s;
  long long ans = 0;
  long long c = -1000, p = -1000;
  long long n = s.size();
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'C') {
      p = -1000;
      if (i - c >= 5) {
        ans++;
        c = i;
      }
    } else {
      c = -1000;
      if (i - p >= 5) {
        ans++;
        p = i;
      }
    }
  }
  cout << ans << "\n";
}
