#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> a;
  a.push(s[0]);
  int ans = 0;
  for (int i = 1; i < s.size(); ++i) {
    if (a.size() && a.top() != s[i]) {
      ans++;
      a.pop();
    } else {
      a.push(s[i]);
    }
  }
  cout << ans;
}
