#include <bits/stdc++.h>
int upll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? -1
         : *(long long*)a > *(long long*)b ? 1
                                           : 0;
}
int downll(const void* a, const void* b) {
  return *(long long*)a < *(long long*)b   ? 1
         : *(long long*)a > *(long long*)b ? -1
                                           : 0;
}
void sortup(long long* a, int n) { qsort(a, n, sizeof(long long), upll); }
void sortdown(long long* a, int n) { qsort(a, n, sizeof(long long), downll); }
long long pom(long long a, long long n, int m) {
  long long x = 1;
  for (a %= m; n; n /= 2) n& 1 ? x = x * a % m : 0, a = a * a % m;
  return x;
}
char s[200010];
int main() {
  scanf("%s", s);
  long long n = strlen(s);
  long long ans = 0;
  for (long long i = (0); i < (n); i++) {
    int t = i;
    while (s[i] == s[i + 1]) i++;
    long long c = i - t + 1;
    ans += c / 3 * 2 + !!(c % 3);
  }
  printf("%lld", ans);
}
