#include <bits/stdc++.h>
const int N = 3e5;
char s[N];
int main() {
  scanf("%s", s);
  int res = 0;
  bool flag = true;
  for (int l = 0, r = 0; true; ++r)
    if (s[r] != s[l]) {
      int run = r - l;
      if (run % 3 != 2) {
        res += (run * 2 + run % 3) / 3;
        flag = true;
      } else {
        res += (run * 2 - 1) / 3;
        res += flag ^= 1;
      }
      if (!s[l = r]) break;
    }
  printf("%d\n", res);
}
