#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  S += "0";
  vector<int> num(N);
  int val = 1;
  int nn = 0;
  for (int i = 1; i < N + 1; i++) {
    if (S[i] == S[i - 1]) {
      val++;
    } else {
      num[nn] = val;
      val = 1;
      nn++;
    }
  }
  bool w = false;
  int ans = 0;
  for (int i = 0; i < nn; i++) {
    if (num[i] % 3 == 0) {
      ans += num[i] / 3 * 2;
      w = false;
    }
    if (num[i] % 3 == 1) {
      ans += num[i] / 3 * 2 + 1;
      w = false;
    }
    if (num[i] % 3 == 2) {
      ans += num[i] / 3 * 2 + 1;
      if (w) {
        ans++;
        w = false;
      } else {
        w = true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
