#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vvl = vector<vl>;
constexpr int MOD = 1000000007;
using long long = long long;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<long long> &v) {
  std::for_each(v.begin(), v.end(), [](long long x) { std::cout << x << " "; });
  std::cout << std::endl;
}
long long dp[201010][3];
int N;
int main() {
  string S;
  cin >> S;
  N = S.length();
  for (long long i = 0; i < (long long)N + 1; i++) {
    for (long long j = 0; j < (long long)3; j++) {
      dp[i][j] = -(1ll << 60);
    }
  }
  dp[0][0] = 0;
  for (long long i = 0; i < (long long)N; i++) {
    for (int pre = 1; pre < 3; pre++) {
      for (int d = 1; d < 3; d++) {
        if (pre == d) {
          if (d == 1) {
            if (S[i - 1] == S[i]) {
              continue;
            }
          } else {
            if (S[i - 2] == S[i] and S[i - 1] == S[i + 1]) {
              continue;
            }
          }
          chmax(dp[i + d][d], dp[i][pre] + 1);
        }
      }
    }
  }
  cout << max(dp[N][1], dp[N][2]) << endl;
  return 0;
}
