#include <bits/stdc++.h>
using namespace std;
char a[300010];
int f[300010];
int main() {
  scanf("%s", a);
  int tot = 1, ans = 0;
  for (int i = 1; i <= strlen(a); ++i) {
    if (i == strlen(a) || a[i] != a[i - 1]) {
      f[++f[0]] = tot;
      tot = 1;
    } else
      tot++;
  }
  for (int i = 1; i <= f[0]; ++i) ans += (f[i] * 2 + 1) / 3;
  for (int i = 2; i <= f[0]; ++i) {
    if (f[i] % 3 == 2 && f[i - 1] % 3 == 2) ans++, f[i] = 0;
  }
  cout << ans << endl;
}
