#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  int64_t n = s.size();
  vector<int64_t> v;
  string las = "x";
  int64_t i = 0;
  while (i + 1 < n) {
    if (las.size() == 1) {
      if (s[i] != las[0]) {
        v.push_back(1);
        las = s.substr(i, 1);
        i++;
      } else {
        v.push_back(2);
        las = s.substr(i, 2);
        i += 2;
      }
    } else if (las.size() == 2) {
      v.push_back(1);
      las = s.substr(i, 1);
      i++;
    } else {
      return -1;
    }
  }
  if (n - 1 - i == 1) {
    v.push_back(2);
    i += 2;
  }
  if (n - 1 - i == 0) {
    v.push_back(1);
    i++;
  }
  if (v[v.size() - 1] == 1 && v[v.size() - 2] == 1 && s[n - 1] == s[n - 2]) {
    v.pop_back();
    v.pop_back();
    v.push_back(2);
  }
  if (v[v.size() - 1] == 2 && v[v.size() - 2] == 2 &&
      s.substr(n - 4, 2) == s.substr(n - 2, 2)) {
    v.pop_back();
    v.pop_back();
    v.push_back(4);
  }
  cout << v.size() << endl;
  return 0;
}
