#include <bits/stdc++.h>
using namespace std;
template <typename TYPE>
inline void chkmax(TYPE &x, TYPE y) {
  x < y ? x = y : 0;
}
template <typename TYPE>
inline void chkmin(TYPE &x, TYPE y) {
  y < x ? x = y : 0;
}
template <typename TYPE>
void readint(TYPE &x) {
  x = 0;
  int f = 1;
  char c;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
const int MAXN = 200005;
int n;
char s[MAXN];
int main() {
  int ans = 0, cur = 0;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = (1); i <= (n + 1); ++i)
    if (s[i] == s[i - 1])
      ++cur;
    else {
      if (!(cur % 3))
        ans += cur / 3 * 2;
      else
        ans += cur / 3 * 2 + 1;
      cur = 1;
    }
  printf("%d\n", ans);
  return 0;
}
