#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<bool> eq(n - 1);
  for (int i = 0; i < n - 1; i++) {
    if (s.at(i + 1) == s.at(i)) {
      eq.at(i) = true;
    } else {
      eq.at(i) = false;
    }
  }
  int count = 0;
  for (int i = 1; i <= n - 3; i++) {
    if (eq.at(i - 1) && eq.at(i + 1)) {
      eq.at(i - 1) = false;
      eq.at(i) = false;
      eq.at(i + 1) = false;
      count++;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    if (i == n - 2 && eq.at(i)) {
      count++;
      break;
    }
    if (eq.at(i)) {
      eq.at(i) = false;
      eq.at(i + 1) = false;
      count++;
    }
  }
  cout << n - count << endl;
}
