#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T> >;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  constexpr int inf = 1e9;
  VV<> dp(n + 1, V<>(3, -inf));
  dp[n][1] = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int x = 1; x <= 2; ++x)
      for (int y = 1; y <= 2; ++y)
        if (dp[i + 1][y] != -inf) {
          if (i + x > n or s.substr(i, x) == s.substr(i + x, y)) continue;
          dp[i][x] = max(dp[i][x], 1 + dp[i + x][y]);
        }
  }
  cout << max(dp[0][1], dp[0][2]) << '\n';
}
