#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> S;
  N = int(S.size());
  stack<int> rem;
  rem.push(S[0]);
  int cnt = 0;
  for (int i = 1; i < N; i++) {
    while (!rem.empty()) {
      if (i >= N - 1) break;
      if (S[rem.top()] != S[i]) {
        i++;
        cnt += 2;
        rem.pop();
      } else {
        break;
      }
    }
    rem.push(S[i]);
  }
  cout << cnt << endl;
  return 0;
}
