#include <bits/stdc++.h>
using namespace std;
const int INF = pow(10, 7);
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  int p = 0, ans = n;
  char c = s[0];
  vector<bool> num;
  int count = 1;
  for (int i = 1; i <= n; i++) {
    if (i == n || s[i] != c) {
      c = s[i];
      ans -= (count + 1) / 3;
      if (count % 3 == 0) {
        num.push_back(false);
      } else if (count % 3 == 1) {
        num.push_back(false);
      } else {
        num.push_back(true);
      }
      count = 1;
    } else {
      count++;
    }
  }
  count = 0;
  bool suc = false;
  num.push_back(false);
  for (int i = 0; i < (int)num.size(); i++) {
    if (num[i]) {
      if (suc)
        count++;
      else {
        suc = true;
        count = 1;
      }
    } else if (suc) {
      suc = false;
      ans += (int)count > 1;
      count = 0;
    }
  }
  cout << ans << endl;
}
