#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  while (getline(cin, s)) {
    stack<char> st;
    int ops = 0;
    int i = 0;
    bool hasOp = 0;
    while (i < s.size()) {
      hasOp = 0;
      if (st.size() > 0 && st.top() != s[i]) {
        st.pop();
        hasOp = 1;
      }
      while (i + 1 < s.size() && s[i] != s[i + 1]) {
        i++;
        hasOp = 1;
      }
      if (hasOp)
        ops++;
      else
        st.push(s[i]);
      i++;
    }
    cout << ops << endl;
  }
}
