#include <bits/stdc++.h>
using namespace std;
inline void Boost() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int NMax = 5050;
const int MOD = 1e9 + 7;
int main() {
  Boost();
  string s;
  cin >> s;
  int n = (int)s.size();
  stack<char> v;
  v.push(s[0]);
  int ans = 0;
  char last = '#';
  for (int i = 1; i < n; ++i) {
    if (v.empty()) {
      v.push(s[i]);
    } else {
      if (s[i] == v.top()) {
        v.push(s[i]);
        continue;
      }
      last = v.top();
      v.pop();
      while (i < n) {
        if (s[i] != last) {
          last = s[i];
          ++i;
        } else {
          if (i + 1 < n && s[i + 1] != s[i]) {
            last = s[i];
            ++i;
          } else {
            break;
          }
        }
      }
      ++ans;
      --i;
    }
  }
  cout << ans;
  return 0;
}
