#include <bits/stdc++.h>
using namespace std;
const int T = 1e5 + 5;
int N = 0;
int len[T], F[T];
int cal(int x) { return x / 3 * 2 + (x % 3 > 0); }
int main() {
  string S;
  cin >> S;
  int cnt = 1;
  for (int i = 1; i < S.size(); i++) {
    cnt += (S[i] == S[i - 1]);
    if (S[i] != S[i - 1] or i == S.size() - 1) {
      len[++N] = cnt;
      cnt = 1;
      if (i == S.size() - 1 and S[i] != S[i - 1]) len[++N] = 1;
    }
  }
  F[0] = 0;
  F[1] = cal(len[1]);
  for (int i = 2; i <= N; i++) {
    F[i] = max(F[i - 1] + cal(len[i]),
               F[i - 2] + cal(len[i - 1] - 1) + cal(len[i] - 1) + 1);
  }
  cout << F[N];
}
