#include <bits/stdc++.h>
using namespace std;
char S[222222];
int main() {
  scanf("%s", S);
  int len = strlen(S);
  int i = 0, j = 0, ans = 0;
  int fwd = 0;
  while (i < len) {
    while (S[i] == S[j] && i < len) {
      i++;
    }
    int num = i - j;
    ans += 2 * ((num + fwd) / 3);
    if ((num + fwd) % 3) ans++;
    if (num % 3 == 2)
      fwd = 1;
    else
      fwd = 0;
    j = i;
  }
  printf("%d", ans);
  return 0;
}
