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