#include <bits/stdc++.h>
using namespace std;
void solve(std::string S) {
  long long N = S.size();
  vector<vector<long long>> dp(N, vector<long long>(3, -255));
  dp[0][1] = 1;
  for (long long i = 1; i < N; i++) {
    if (S[i] != S[i - 1]) {
      dp[i][1] = max(dp[i - 1][1], dp[i - 1][2]) + 1;
      if (i - 3 >= 0) dp[i][2] = max(dp[i - 3][1], dp[i - 3][2]);
    } else {
      dp[i][1] = max(dp[i - 1][1], dp[i - 1][2]);
      if (i - 3 >= 0) dp[i][2] = max(dp[i - 3][1], dp[i - 3][2]) + 2;
    }
  }
  cout << *max_element(dp[N - 1].begin(), dp[N - 1].end()) << endl;
}
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}
