#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<int> num;
  int count = 1;
  for (int i = 1; i <= n; i++) {
    if (i == n || s[i] != c) {
      c = s[i];
      if (count <= 1)
        num.push_back(0);
      else
        num.push_back(count);
      count = 1;
    } else {
      count++;
    }
  }
  for (int i = 1; i < (int)num.size(); i++) {
    if (num[i - 1] * num[i] != 0) {
      ans--;
      num[i - 1]--;
      num[i]--;
    }
  }
  for (int i = 0; i < (int)num.size(); i++) {
    if (num[i] == 0) continue;
    if (num[i] % 3 == 2) {
      ans -= (num[i] + 1) / 3;
    } else {
      ans -= num[i] / 3;
    }
  }
  cout << ans << endl;
}
