#include <bits/stdc++.h>
int res(std::string S) {
  int len = S.length(), zero = 0, one = 0, q = 0, diff;
  for (int i = 0; i < len; ++i) {
    if (S[i] == '?')
      q++;
    else if (S[i] == '0')
      zero++;
    else
      one++;
  }
  diff = abs(zero - one);
  q -= diff;
  if (q % 2 == 0)
    return diff;
  else
    return q;
}
int main() {
  std::string S;
  std::cin >> S;
  std::cout << res(S) << std::endl;
  return 0;
}
