#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long int c = 0, t = 0, d = 0, m, n;
  cin >> s;
  for (long long int i = 0; i < s.length(); i++) {
    if (s[i] == '0')
      c++;
    else if (s[i] == '1')
      t++;
    else if (s[i] == '?')
      d++;
  }
  if (d % 2 == 1) {
    m = max(c, t) + (d / 2 + 1);
    n = min(c, t) + (d / 2);
    cout << abs(m - n);
  } else {
    cout << abs(c - t);
  }
  return 0;
}
