#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
char s[maxn];
int ans;
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    int j = i;
    while (j <= n && s[j] == s[i]) j++;
    j--;
    if (j - i + 1 == 1) {
      ans++;
      i = j;
      continue;
    }
    int len = j - i + 1;
    ans += 2 * ((len) / 3);
    if (len % 3 == 1) {
      if (j < n)
        ans += 2;
      else
        ans++;
      i = j + 1;
      continue;
    } else if (len % 3 == 2) {
      if (j < n) {
        ans += 2;
      } else
        ans++;
      i = j + 1;
      continue;
    }
    i = j;
  }
  printf("%d\n", ans);
}
