#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int dp[N][3];
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  if (n == 1) {
    cout << 1;
    return 0;
  }
  dp[0][1] = 1;
  dp[0][2] = 0;
  dp[1][2] = 2 * (int)(s[1] != s[0]);
  dp[1][2] = 1;
  for (int i = 2; i < n; ++i) {
    dp[i][1] = 0;
    if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], 1 + dp[i - 1][1]);
    dp[i][1] = max(dp[i][1], 1 + dp[i - 1][2]);
    dp[i][2] = 0;
    dp[i][2] = max(dp[i][2], 1 + dp[i - 2][1]);
    if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3]))
      dp[i][2] = max(dp[i][2], 1 + dp[i - 2][2]);
  }
  cout << max(dp[n - 1][1], dp[n - 1][2]);
}
