#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long cnt = 0, ans = 0;
  vector<long long> v;
  char ls = '0';
  for (auto c : s) {
    if (c != ls) {
      ans += 2 * (cnt / 3);
      cnt %= 3;
      v.push_back(cnt);
      cnt = 1;
    } else
      cnt++;
    ls = c;
  }
  ans += 2 * (cnt / 3);
  cnt %= 3;
  v.push_back(cnt);
  while (!v.empty()) {
    long long d = v.back();
    v.pop_back();
    if (d == 0) continue;
    if (d == 1) {
      ans++;
      continue;
    }
    if (!v.empty() && v.back() == 2) {
      ans += 3;
      v.pop_back();
      continue;
    }
    ans++;
  }
  cout << ans << "\n";
  return 0;
}
