#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  std::cin >> s;
  long long n = s.length();
  long long result = n;
  vector<long long> res;
  char now = s[0];
  long long len = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == now) {
      len++;
    } else {
      res.push_back(len);
      len = 1;
      now = s[i];
    }
  }
  res.push_back(len);
  for (int i = 0; i < res.size() - 1; i++) {
    if (res[i] % 3 == 2 && res[i + 1] % 3 == 2) {
      res[i]--;
      res[i + 1]--;
      result--;
    }
    int x = (res[i] + 2) / 3 * 2;
    if (res[i] % 3 != 0) {
      x--;
    }
    result -= (res[i] - x);
  }
  int x = (res[res.size() - 1] + 2) / 3 * 2;
  if (res[res.size() - 1] % 3 != 0) {
    x--;
  }
  result -= (res[res.size() - 1] - x);
  std::cout << result << std::endl;
}
