#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
struct Fll {
  LL first, second, third, fourd;
};
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
struct Edge {
  LL to, cost;
};
struct edge {
  LL from, to, cost;
};
vector<vector<Edge>> g;
vector<edge> edges;
vector<pair<LL, LL>> v;
map<pair<LL, LL>, pair<LL, LL>> ma;
set<LL> st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000],
    dp[210000][2];
string str, ss;
bool f;
char c;
int di[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int main() {
  cin >> str;
  n = str.size();
  for (int i = 0; i < n; i++) {
    if (i) {
      if (str[i] == str[i - 1]) {
        dp[i + 2][1] = max(dp[i + 2][1], dp[i][0] + 1);
        dp[i + 1][0] = max({dp[i + 1][0], (i > 0 ? dp[i][1] + 1 : 0LL)});
      } else {
        dp[i + 2][1] = max(dp[i + 2][1], dp[i][0] + 1);
        dp[i + 1][0] =
            max({dp[i + 1][0], dp[i][0] + 1, (i > 0 ? dp[i][1] + 1 : 0LL)});
      }
    }
    if (i >= 2) {
      if (str[i - 2] == str[i] && str[i - 1] == str[i + 1]) {
      } else {
        dp[i + 2][1] = max(dp[i + 2][1], dp[i - 2][1] + 1);
      }
    }
  }
  cout << max(dp[n][0], dp[n][1]) << endl;
  return 0;
}
