#include <bits/stdc++.h>
using namespace std;
string s;
bool ok(int i) { return i == 1 || (s[i] != s[i - 1] && s[i - 1] != s[i - 2]); }
bool ok2(int j) {
  return j < 4 || (s[j - 1] != s[j - 3] && s[j - 2] != s[j - 4]);
}
int f[200005], g[200005];
int main() {
  cin >> s;
  s += '*';
  int n = s.length();
  f[0] = 0;
  g[0] = 0;
  for (int i = 1; i < n; i++) {
    if (ok(i)) {
      f[i] = f[i - 1] + 1;
    }
    if (ok2(i) && i > 1) {
      g[i] = g[i - 2] + 1;
    }
    if (i > 1) {
      g[i] = max(g[i], f[i - 2] + 1);
    }
    f[i] = max(f[i], g[i - 1] + 1);
  }
  cout << max(g[n - 1], f[n - 1]);
  return 0;
}
