#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0, j = 0, n = S.size();
  vector<int> cnt(0);
  S += "0";
  for (int i = 0; i < n; i++) {
    if (S.at(i) != S.at(i + 1)) {
      cnt.push_back(++j);
      j = 0;
    } else {
      j++;
    }
  }
  j = 0;
  int N = cnt.size();
  cnt.push_back(0);
  for (int i = 0; i < N; i++) {
    if (cnt.at(i) == 2 && cnt.at(i + 1) == cnt.at(i)) {
      j++;
    } else {
      if (j) {
        ans += j + 2;
        j = 0;
        continue;
      }
      if (cnt.at(i) == 1 || cnt.at(i) == 2)
        ans++;
      else
        ans += ((cnt.at(i) + 2) / 3) * 2;
    }
  }
  cout << ans << endl;
}
