#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  string S;
  cin >> S;
  vector<bool> sp(S.size() - 1, true);
  vector<bool> pb(S.size() - 1, false);
  for (int i = 0, i_len = (S.size() - 1); i < i_len; ++i) {
    if (S[i] == S[i + 1]) pb[i] = true;
  }
  for (int i = (1); i < (S.size() - 2); ++i) {
    if (pb[i - 1] == pb[i + 1] && pb[i - 1] == true) {
      sp[i] = false;
      pb[i - 1] = false;
      pb[i + 1] = false;
    }
  }
  long long ans = S.size() - 1;
  for (int i = 0, i_len = (S.size() - 1); i < i_len; ++i) {
    if (pb[i] || !sp[i]) ans--;
  }
  cout << ans + 1 << endl;
  return 0;
}
