#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  s += '*';
  int n = s.length();
  int res = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cnt++;
      continue;
    }
    if (s[i] == s[i - 1]) {
      cnt++;
    } else {
      while (cnt > 2) {
        cnt -= 3;
        res += 2;
      }
      res += (cnt > 0);
      cnt = 1;
    }
  }
  cout << res;
  return 0;
}
