#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char old = s[0];
  long long count = 0;
  bool flag = false;
  long long temp_count = 1;
  for (int i = 1; i < s.size(); i++) {
    if (old == s[i]) {
      temp_count++;
    } else {
      count += temp_count / 3 * 2;
      int mod = temp_count % 3;
      if (mod > 0) {
        count++;
      }
      if (mod > 1) {
        if (flag) {
          count++;
          flag = false;
        } else {
          flag = true;
        }
      } else {
        flag = false;
      }
      temp_count = 1;
    }
    old = s[i];
  }
  count += temp_count / 3 * 2;
  int mod = temp_count % 3;
  if (mod > 0) {
    count++;
  }
  if (mod > 1) {
    if (flag) {
      count++;
    }
  }
  cout << count;
}
