#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int onenum = 0, zeronum = 0, qnum = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '0')
      zeronum++;
    else if (S[i] == '1')
      onenum++;
    else
      qnum++;
  }
  int sub = abs(zeronum - onenum);
  if (sub >= qnum) {
    cout << sub - qnum << endl;
    return 0;
  } else {
    if ((qnum - sub) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << 1 << endl;
      return 0;
    }
  }
}
