#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  int counter = 0;
  cin >> str;
  for (int i = 0; i < str.size() - 1; i++) {
    int num_same = 0;
    int j = i;
    while (str.at(i) == str.at(j)) {
      num_same++;
      j++;
      if (j == str.size()) {
        break;
      }
    }
    if (num_same % 3 == 2) {
      counter += (num_same / 3 + 1);
    } else {
      counter += (num_same / 3);
    }
    i = j - 1;
  }
  cout << str.size() - counter << endl;
}
