#include <bits/stdc++.h>
std::vector<int> remainder;
void calc(int num, int *res) {
  *res += num / 3 * 2;
  int r = num % 3;
  if (r != 0) ++(*res);
  remainder.emplace_back(r);
}
int solve(const std::string &s) {
  int res = 0;
  int num = 1;
  for (int i = 1; i < s.length(); ++i) {
    if (s[i] == s[i - 1]) {
      ++num;
    } else {
      calc(num, &res);
      num = 1;
    }
  }
  calc(num, &res);
  for (int i = 1; i < remainder.size(); ++i) {
    if (remainder[i - 1] == 2 && remainder[i] == 2) {
      ++res;
      ++i;
    }
  }
  return res;
}
int main() {
  std::string s;
  std::cin >> s;
  std::cout << solve(s) << std::endl;
  return 0;
}
