#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sSize = s.length();
  int cnt = 0, f = 0;
  for (int i = 1; i < sSize; i++) {
    if (s[i - 1] == s[i]) {
      if (!cnt) cnt++;
      cnt++;
    } else {
      if (cnt == 2 && !f) {
        f = 1;
      } else if (cnt == 2 && f) {
        s[i - 1] = '1';
        f = 0;
      } else if (cnt != 2) {
        f = 0;
      }
      cnt = 0;
    }
  }
  int temp = 0, ans = 0;
  for (int i = 1; i < sSize; i++) {
    if (s[i - 1] == s[i]) {
      if (!temp) temp++;
      temp++;
    } else {
      if (temp > 0) {
        if (temp == 3)
          ans += 2;
        else {
          temp /= 2;
          ans += temp + (temp / 2);
        }
      } else
        ans++;
      temp = 0;
    }
  }
  if (!temp) temp++;
  if (temp > 0) {
    if (temp > 1) temp /= 2;
    ans += temp + (temp / 2);
  }
  cout << ans << endl;
  return 0;
}
