#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int len, out;
  string s;
  cin >> s;
  len = (int)s.length();
  out = (int)s.length();
  int cnt = 1;
  for (int i = 0; i < len - 1; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
    } else {
      int a = 0;
      if (cnt % 3 == 0 || cnt % 3 == 1) {
        a = cnt / 3;
      } else {
        a = cnt / 3 + 1;
      }
      if (cnt == 1) {
        continue;
      } else {
        out -= a;
        cnt = 1;
      }
    }
  }
  int a = 0;
  if (cnt % 3 == 0 || cnt % 3 == 1) {
    a = cnt / 3;
  } else {
    a = cnt / 3 + 1;
  }
  if (cnt == 1) {
  } else {
    out -= a;
    cnt = 1;
  }
  cout << out;
  return 0;
}
