#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
  string S;
  cin >> S;
  const ll N = S.size();
  if (N == 2 && S[0] == S[1]) {
    cout << 1 << endl;
    return 0;
  }
  vector<vector<ll>> dp(N, vector<ll>(2, 0));
  dp[0][0] = 1;
  dp[0][1] = INT_MIN;
  for (ll i = 1; i < N; i++) {
    dp[i][0] = dp[i - 1][1] + 1;
    if (S[i] != S[i - 1]) {
      dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
    }
    if (i == 1) {
      continue;
    }
    dp[i][1] =
        max(dp[i - 2][0] + 1,
            dp[i - 2][1] + (i < 3 || S[i] != S[i - 2] || S[i - 1] != S[i - 3]));
  }
  cout << max(dp[N - 1][0], dp[N - 1][1]) << endl;
}
