#include <bits/stdc++.h>
using namespace std;
pair<int, int> operator +(pair<int, int> a, int val) {
  auto func = [&] (int x) {
    return (x / 3) * 2 + (x % 3 != 0);
  };
  pair<int, int> res = {max(a.second + func(val - 1) + 1, a.first + func(val)),
                        a.first + func(val - 1)
                       };
  if (func >= 2) {
    res.second = max(res.second, a.second + func(val - 2) + 1);
  }
  return res;
}
int main() {
  string str;
  cin >> str;
  vector<int> vec;
  for (int i = 0, j = 0; i < str.size(); i++) {
    if (i + 1 == str.size() || str[i] != str[i + 1]) {
      vec.push_back(i - j + 1);
      j = i + 1;
    }
  }
  pair<int, int> current = {0, INT_MIN};
  for (int val : vec) {
    current = current + val;
  }
  cout << current.first << endl;
  return 0;
}
