#include <bits/stdc++.h>
char s[200050], c[200050];
int cnt[200050];
int main() {
  int n, m = 1, i, ans = 0;
  scanf("%s", s);
  n = strlen(s);
  c[1] = s[0];
  cnt[1] = 1;
  for (i = 1; i < n; ++i)
    if (s[i] != c[m]) {
      c[++m] = s[i];
      cnt[m] = 1;
    } else
      ++cnt[m];
  for (i = m - 1; i; --i)
    if (cnt[i] % 3 == 2 && cnt[i + 1] % 3 == 2) {
      --cnt[i];
      --cnt[i + 1];
      ++ans;
    }
  for (i = 1; i <= m; ++i) ans += cnt[i] / 3 * 2 + (cnt[i] % 3 != 0);
  printf("%d\n", ans);
  return 0;
}
