#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  int n = s.size(), i, j, o = 0, z = 0, q = 0;
  for (i = 0; i < n; i++) {
    o += (s[i] == '0');
    z += (s[i] == '1');
    q += (s[i] == '?');
  }
  if (o < z) {
    j = q / 2;
    z += j;
    o += q - j;
  } else if (o > z) {
    j = q / 2;
    o += q / 2;
    z += q - j;
  } else {
    o += q / 2;
    j = q / 2;
    z += q - j;
  }
  cout << abs(o - z) << endl;
}
