#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
const long long LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;
  cin >> s;
  long long n = s.size();
  long long dp[200010][3];
  for (long long i = 0; i < n + 1; i++)
    for (long long j = 0; j < 3; j++) dp[i][j] = 0;
  dp[0][1] = 1, dp[0][2] = 0;
  dp[1][2] = 1;
  if (s[0] == s[1])
    dp[1][1] = 0;
  else
    dp[1][2] = 2;
  for (long long i = 2; i < n; i++) {
    if (s[i] != s[i - 1]) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1);
    dp[i][1] = max(dp[i][1], dp[i - 1][2] + 1);
    dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1);
    if (i >= 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3]))
      dp[i][2] = max(dp[i][2], dp[i - 2][1] + 1);
  }
  cout << max(dp[n - 1][1], dp[n - 1][2]) << endl;
  return 0;
}
