#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int n = S.size();
  int t = 0;
  int ans = 0;
  while (t == 0) {
    t = 1;
    for (int i = 0; i < n - 1; i++) {
      if (S[i] != S[i + 1]) {
        S.erase(i, 2);
        t = 0;
        ans++;
        ans++;
        i = i - 1;
        n = n - 2;
      }
    }
  }
  cout << ans << endl;
}
