#include <bits/stdc++.h>
using std::abs;
using std::array;
using std::cerr;
using std::cin;
using std::cout;
using std::generate;
using std::get;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tuple;
using std::unique;
using std::vector;
template <typename T>
T input() {
  T res;
  cin >> res;
  {};
  return res;
}
template <typename IT>
void input_seq(IT b, IT e) {
  std::generate(b, e,
                input<typename std::remove_reference<decltype(*b)>::type>);
}
int main() {
  std::iostream::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string s;
  cin >> s;
  int ans = 0;
  pair<char, int> last = {-1, -1};
  for (int i = 0; i != int((s).size());) {
    int i0 = i;
    while (i != int((s).size()) and s[i] == s[i0]) ++i;
    int len = i - i0;
    int k = 1;
    while ((k + 1) * (k + 2) / 2 <= len) ++k;
    while (len != 0) {
      if (last.first != s[i0]) {
        len -= 1;
        last = {s[i0], 1};
        ++ans;
      } else {
        int take = last.second + 1;
        if (take <= len) {
          len -= take;
          last.second = take;
          ++ans;
        } else {
          if (i != int((s).size())) ++ans, ++i;
          len = 0;
          last = {-1, -1};
        }
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
