#include <bits/stdc++.h>
using namespace std;
int getLen(int n);
int main() {
  string str;
  cin >> str;
  int max = 0;
  char last = '\0';
  int lastlen = 0;
  bool flag = false;
  for (char c : str) {
    if (c == last) {
      lastlen++;
    } else {
      last = c;
      if (lastlen % 3 == 2) {
        if (flag) {
          max += 1;
          flag = false;
        } else {
          flag = true;
        }
      } else {
        flag = false;
      }
      max += getLen(lastlen);
      lastlen = 1;
    }
  }
  if (lastlen % 3 == 2 && flag) {
    max += 1;
  }
  max += getLen(lastlen);
  cout << max << endl;
}
int getLen(int n) { return (n / 3) * 2 + (n % 3 == 0 ? 0 : 1); }
