#include <bits/stdc++.h>
int main() {
  using namespace std;
  string S;
  cin >> S;
  int i(0), sum(0), N = S.length(), N0 = N;
  bool x;
  do {
    x = false;
    for (i = 0; i < N - 1; i++) {
      while (S[i] != S[i + 1] && i < N - 1) {
        S.erase(i, 2);
        N -= 2;
        x = true;
      }
    }
  } while (x == true);
  cout << N0 - N << endl;
}
