#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<char, int> m;
  for (int i = 0; i < s.size(); i++) {
    m[s[i]]++;
  }
  int un = m['1'] - m['0'];
  if (un < 0) {
    un = -un;
  }
  if (m['?'] % 2 == 0) {
    cout << un;
  }
  if (un != 0 && m['?'] % 2 != 0) {
    cout << un - 1;
  }
  if (un == 0 && m['?'] % 2 != 0) {
    cout << un + 1;
  }
}
