#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> a;
  char fro = s[0];
  int ans = 0;
  for (int i = 0; i < (s.size()); i++) {
    if (s[i] == fro) {
      a.push(fro);
    } else {
      if (!a.empty()) {
        a.pop();
        ans += 2;
      }
    }
  }
  cout << ans << endl;
}
