#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int l = str.length(), c = 0, c1 = 0, c2 = 0;
  for (int i = 0; i < l; i++) {
    if (str[i] == '1')
      c++;
    else if (str[i] == '0')
      c1++;
    else
      c2++;
  }
  if (c2 % 2 == 0) {
    if (c == c1)
      cout << "0";
    else if (c > c1)
      cout << abs(c - c1);
    else
      cout << abs(c1 - c);
  } else {
    if (c == c1)
      cout << "1";
    else if (c > c1)
      cout << abs(c - c1) - 1;
    else
      cout << abs(c1 - c) - 1;
  }
  return 0;
}
