#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int start = 0;
  int compare = start + 1;
  int count = 0;
  priority_queue<int> bs;
  while (compare < S.size()) {
    if (S[start] != S[compare]) {
      count += 2;
      while (true) {
        if (start > bs.top()) {
          start = bs.top();
          compare++;
          break;
        }
        if (bs.top() == 0) {
          start = compare + 1;
          compare = start + 1;
          break;
        }
        bs.pop();
      }
    } else {
      bs.push(start);
      start = compare;
      compare = start + 1;
    }
  }
  cout << count << endl;
  return 0;
}
