#include <bits/stdc++.h>
using namespace std;
char c[200020];
int main() {
  cin >> c;
  int now = 0;
  char last;
  int ans = 0;
  last = c[0];
  int n = strlen(c) - 1;
  while (1) {
    if (now >= strlen(c) - 1) {
      break;
    }
    if (c[now + 1] == last && n - now + 1 >= 3) {
      if (n - now + 1 == 1) {
        ans++;
        break;
      }
      if (n - now + 1 == 2) {
        ans++;
        if (c[n] != c[n - 1]) {
          ans++;
        }
        break;
      }
      if (n - now + 1 == 3) {
        if (c[n] != c[n - 1] && c[n - 1] != c[n - 2]) {
          ans++;
        }
        ans += 2;
        break;
      }
    }
    if (c[now + 1] == last) {
      now += 4;
      ans += 3;
      last = c[now];
    } else {
      ans++;
      now++;
      last = c[now];
    }
  }
  printf("%d\n", ans);
}
