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