#include <bits/stdc++.h>
char s[100010];
int main() {
  scanf("%s", s + 1);
  int L = strlen(s + 1), ans = 0;
  for (int i = 1, j; i <= L; ++i) {
    for (j = i; s[j] == s[j + 1]; ++j)
      ;
    int l = j - i + 1;
    switch (l % 3) {
      case 0:
        ans += l / 3 * 2;
        break;
      case 1:
        ans += l / 3 * 2 + 1;
        break;
      case 2:
        ans += l / 3 * 2 + 2, ++j;
        break;
    }
    j > L&& l % 3 == 2 && (--ans);
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}
