#include <bits/stdc++.h>
using namespace std;
int sum[1000005], ans = 0, a = 0, b = 0, c = 0;
string s;
int main() {
  cin >> s;
  int x = s.size();
  for (int i = 1; i <= x; i++) {
    if (s[i] == '1') {
      a++;
    }
    if (s[i] == '2') {
      b++;
    }
    if (s[i] == '?') {
      c++;
    }
  }
  if (a > b) {
    ans = a - b;
  } else {
    ans = b - a;
  }
  if (c > ans) {
    ans = (c - ans) % 2;
  } else {
    ans -= c;
  }
  cout << ans;
}
