#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[N];
int K, cnt = 1;
string S = "", tmp;
vector<int> vec;
bool check(int x) {
  if (x <= 1) return 0;
  return x <= 2 || x % 2 == 1;
}
signed main() {
  cin >> (s + 1);
  int n = strlen(s + 1);
  for (int i = 2; i <= n; ++i)
    if (s[i] == s[i - 1])
      ++cnt;
    else
      vec.push_back(cnt), cnt = 1;
  if (cnt) vec.push_back(cnt);
  K = vec.size();
  for (int i = 0; i < vec.size(); ++i) {
    int v = vec[i];
    if (v == 1) continue;
    if (i != vec.size() - 1) {
      if (check(vec[i]) && check(vec[i + 1])) ++K, --vec[i], --vec[i + 1];
    }
    K += (vec[i] <= 2 ? 0 : vec[i] / 2);
  }
  cout << K;
  return 0;
}
