#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long N = 200005;
string s;
long long d[N][2];
bool v[N][2];
long long dp(long long u, long long t) {
  if (v[u][t]) return d[u][t];
  if (u == 0) return 0;
  long long &ans = d[u][t];
  v[u][t] = 1;
  if (t == 1) {
    if (u - 1 >= 2) ans = max(ans, 1 + dp(u - 1, 2));
    if (u - 1 >= 1)
      if (s[u] != s[u - 1]) ans = max(ans, 1 + dp(u - 1, 1));
  } else {
    if (u - 2 >= 2)
      if (s[u] != s[u - 2] && s[u - 1] != s[u - 3])
        ans = max(ans, 1 + dp(u - 2, 2));
    if (u - 2 >= 1) ans = max(ans, 1 + dp(u - 2, 1));
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  s += '~';
  cout << max(dp(s.size() - 1, 1), dp(s.size() - 1, 2));
}
