#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
const long long INFLL = 1LL << 60;
const int INFI = 1000000000;
int main() {
  string S;
  cin >> S;
  int len = S.size();
  int count = 1;
  for (int i = 0; i < len; i++) {
    if (S[i] == S[i + 1]) {
      count++;
      if (S[i + 1] != S[i + 2] || i == len - 2) {
        len -= (count + 1) / 3;
        count = 1;
      }
    }
  }
  cout << len << endl;
}
