#include <bits/stdc++.h>
using namespace std;
int f(int n) {
  if (n % 3 == 0)
    return n / 3 * 2;
  else
    return n / 3 * 2 + 1;
}
int main() {
  string s;
  cin >> s;
  std::vector<int> vec(s.size());
  vec[0] = 1;
  for (int i = 1; i < s.size(); ++i) {
    if (s[i - 1] == s[i]) {
      vec[i] = vec[i - 1] + 1;
    } else
      vec[i] = 1;
  }
  vec.emplace_back(1);
  std::vector<int> vec2;
  for (int i = 0; i < s.size(); ++i) {
    if (vec[i + 1] == 1) {
      vec2.emplace_back(vec[i]);
    }
  }
  int cnt = 0;
  for (int i = 0; i < vec2.size(); ++i) {
    if (i == vec2.size() - 1) {
      cnt += f(vec2[i]);
      continue;
    }
    if (vec2[i] != 2) {
      cnt += f(vec2[i]);
    } else {
      if (vec2[i + 1] != 2)
        cnt += f(vec2[i]);
      else {
        cnt += 3;
        i++;
      }
    }
  }
  cout << cnt;
}
