#include <bits/stdc++.h>
using namespace std;
constexpr int Inf = 1000000000;
constexpr long long INF = 9 * 1e18;
constexpr long long MOD = 1000000007;
const double PI = 3.1415926535897;
int dp[200020][3];
int main() {
  string S;
  cin >> S;
  int N = S.size();
  S += "####";
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = -Inf;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 1; k < 3; k++) {
        if (dp[i][j] >= 0) {
          if (j == k) {
            if (S.at(i - 1) == S.at(i)) {
              continue;
            } else {
              if (S.at(i - 2) == S.at(i) && S.at(i - 1) == S.at(i + 1)) {
                continue;
              }
            }
          }
          dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
        }
      }
    }
  }
  cout << max(dp[N][1], dp[N][2]) << endl;
}
