#include <bits/stdc++.h>
using namespace std;
int rept(int l) {
  int r = l % 3, m = l - r, n = 0;
  if (r == 0) {
    n = 0;
  } else {
    n = 1;
  }
  return 2 * round(m / 3) + n;
}
int main() {
  string s;
  cin >> s;
  s = s + '0';
  int n = s.size(), c = 1, ans = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == s[i]) {
      c++;
    } else {
      ans += rept(c);
      c = 1;
    }
  }
  cout << ans;
}
