#include <bits/stdc++.h>
using namespace std;
template <typename qwq>
inline void read(qwq& x) {
  x = 0;
  register int f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  x *= f;
}
template <typename qaq>
inline void print(qaq x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int cnt = 1, ans, flag;
char last;
int tmp[233333];
char s[233333];
int main() {
  scanf("%s", s + 1);
  register int len = strlen(s + 1);
  last = s[1];
  ans = 1;
  for (register int i = 2; i <= len; ++i) {
    if (s[i] == last) {
      ++tmp[cnt];
      if (tmp[cnt] == 1) --ans;
      continue;
    }
    if (s[i] != last && tmp[cnt]) {
      ++tmp[cnt];
      if (tmp[cnt] == 2) {
        ans += 2;
        ++i;
        ++cnt;
        last = s[i];
        if (i != len + 1) ++ans;
        continue;
      } else {
        register int res = tmp[cnt] % 3;
        register int div = tmp[cnt] / 3;
        ans += div * 2 + res;
      }
      ++cnt;
    }
    ++ans;
    last = s[i];
  }
  if (tmp[cnt]) {
    ++tmp[cnt];
    if (tmp[cnt] == 2) {
      ++ans;
    } else {
      register int res = tmp[cnt] % 3;
      register int div = tmp[cnt] / 3;
      ans += div * 2 + res;
    }
  }
  print(ans);
}
