#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
bool check(int n) {
  bool ans = false;
  if (n == 2 || n == 4) ans = true;
  if (n > 4 && n % 2 == 1) ans = true;
  return ans;
}
int main() {
  string s;
  int cnt = 1, sum = 0;
  cin >> s;
  char c = 'Z';
  vector<int> rang;
  for (auto ss : s) {
    if (c == ss)
      cnt++;
    else {
      rang.push_back(cnt);
      cnt = 1;
      c = ss;
    }
  }
  rang.push_back(cnt);
  rang.erase(rang.begin());
  for (int i = 0; i < rang.size() - 1; i++) {
    if (rang[i] == 1) {
      if (check(rang[i + 1])) {
        rang[i + 1]--;
      }
      sum++;
    } else {
      int tmp = ceil((double(rang[i]) / 2.0));
      sum += tmp;
      if (check(rang[i]) && check(rang[i + 1])) {
        sum++;
        rang[i + 1]--;
      }
    }
  }
  sum += ceil(double((double(rang[rang.size() - 1]) / 2.0)));
  cout << sum << endl;
}
