#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() == 1) {
    cout << 1 << endl;
    return 0;
  }
  s = s + "N";
  vector<int> C;
  long long ans = 0;
  char c = s[0];
  int cnt = 1;
  for (int i = 1; i < s.size(); i++) {
    if (c != s[i]) {
      c = s[i];
      C.push_back(cnt);
      cnt = 1;
      continue;
    }
    cnt++;
  }
  if (C.size() == 1) {
    ans += C[0] / 3 * 2;
    if (C[0] % 3 != 0) ans++;
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i < C.size(); i++) {
    if (C[i] == 1)
      ans += 1;
    else if (C[i] == 2) {
      if (i < C.size() - 1 && C[i + 1] == 2) {
        ans += 2;
        C[i + 1]--;
      } else {
        ans += 1;
      }
    } else {
      ans += C[i] / 3 * 2;
      if (C[i] % 3 != 0) ans++;
    }
  }
  cout << ans << endl;
}
