#include <bits/stdc++.h>
using namespace std;
char str[200005];
int main() {
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  int s = 0, len = 0;
  bool v = 0;
  for (int i = 1; i <= n; i++) {
    len++;
    if (i == n || str[i] != str[i + 1]) {
      if (len % 3 == 0) {
        v = 0;
        s += len / 3 * 2;
      } else if (len % 3 == 1) {
        v = 0;
        s += len / 3 * 2 + 1;
      } else {
        s += len / 3 * 2 + 1;
        if (v) {
          s++;
          v = 0;
        } else
          v = 1;
      }
      len = 0;
    }
  }
  printf("%d\n", s);
  return 0;
}
