#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int s = S.size();
  int zero = 0;
  int one = 0;
  for (int i = 0; i < s; i++) {
    if (S.at(i) == '0') {
      zero += 1;
    } else if (S.at(i) == '1') {
      one += 1;
    } else {
      if (zero - one < 0) {
        S.at(i) = '0';
      } else {
        S.at(i) = '1';
      }
    }
  }
  if (zero - one < 0) {
    cout << one - zero << endl;
  } else {
    cout << zero - one << endl;
  }
}
