#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-2;
const long double pi = acos(-1.0);
int main() {
  stack<char> st;
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    char t = s[i];
    if (!st.empty() && st.top() != t) {
      ans++;
      st.pop();
    } else
      st.push(t);
  }
  cout << ans << endl;
  return 0;
}
