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