#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int main(void) {
  string S;
  cin >> S;
  list<char> l;
  deque<char> deq;
  deq.push_back(S[0]);
  for (int i = 1; i < S.length(); ++i) {
    if (S[i] != deq.back()) {
      (deq.size() == 1) ? deq.pop_front() : deq.pop_back();
    } else {
      deq.push_back(S[i]);
    }
  }
  lint ans = S.length() - deq.size();
  cout << ans << endl;
  return 0;
}
