#include <bits/stdc++.h>
using namespace std;
long long n, h[100005];
long long dp[1000005];
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
stack<long long> sta;
queue<long long> que;
deque<long long> dque;
set<string> s_set;
int vis[200001];
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int gcd(const vector<int> &v) {
  int ret = v[0];
  for (int i = 1; i < v.size(); i++) ret = gcd(ret, v[i]);
  return ret;
}
int lcm(const vector<int> &v) {
  int ret = v[0];
  for (int i = 1; i < v.size(); i++) ret = lcm(ret, v[i]);
  return ret;
}
struct Student {
  string name;
  int no, point;
};
bool comp(const Student &a, const Student &b) {
  if (a.name != b.name) return a.name < b.name;
  if (a.point != b.point) return a.point > b.point;
  return a.no < b.no;
}
std::string replaceOtherStr(std::string &replacedStr, std::string from,
                            std::string to) {
  const unsigned int pos = replacedStr.find(from);
  const int len = from.length();
  if (pos == std::string::npos || from.empty()) {
    return replacedStr;
  }
  return replacedStr.replace(pos, len, to);
}
void countPN(int n, std::vector<int> &count) {
  int m = n;
  for (int i = 2; i * i <= n; ++i) {
    while (m % i == 0) {
      m /= i;
      count[i]++;
    }
    if (m == 1) break;
  }
  if (m != 1) count[m]++;
}
int main() {
  long long A, B, C, D, E, F, G, H, I, J, L, N, M, K, O, P, Q, R, S, T, U, V, W,
      X, Y, Z;
  long long sum, sum1, sum2, sum3, sum4;
  sum = sum1 = sum2 = sum3 = sum4 = 0;
  long long flg, flg1, flg2, flg3, cnt, cnt1, cnt2, cnt3, cnt4;
  flg = flg1 = flg2 = flg3 = cnt = cnt1 = cnt2 = cnt3 = cnt4 = 0;
  long long max;
  long long max1;
  max = max1 = 0;
  long long min;
  long long min1;
  min = min1 = 1000000000;
  long long wk, wk1, wk2, wk3, wk4;
  wk = wk1 = wk2 = wk3 = wk4 = 0;
  bool f;
  long long ans = 0;
  string s, t;
  std::cin >> s;
  for (long long i = 0; i < s.length() - 1; i++) {
    if ((s[i] != s[i + 1] && (flg != 1 || cnt1 != 0)) ||
        (s[i] != s[i + 1] && flg2 == 1)) {
      cnt++;
      flg = 0;
      cnt1 = 0;
      flg2 = 0;
    } else if (s[i] != s[i + 1]) {
      flg = 0;
      cnt1 = 0;
      flg3 = 1;
      flg2 = 1;
    } else if (s[i] == s[i + 1]) {
      if (flg == 1) {
        cnt1++;
        flg2 = 0;
        if (cnt1 >= 2) {
          cnt++;
          flg = 0;
          cnt1 = 0;
        }
      } else if ((flg == 0 && i + 1 != s.length() - 1) ||
                 (flg == 0 && flg3 == 1)) {
        cnt++;
        flg = 1;
      }
      flg3 = 0;
    }
  }
  printf("%lld", cnt + 1);
  return 0;
  if (1) {
    printf("%lld", N);
  } else {
  }
  return 0;
}
