#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const long long MOD2 = 998244353;
const long long N = 1000 * 100 + 10;
const long long N2 = 70;
const long double PI = 3.141592653589793;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void solve() {}
signed main() {
  string s;
  cin >> s;
  long long cnt = 0, n = s.length();
  for (long long i = 0; i < n; i++) {
    if (s[i] == '1') {
      cnt++;
    } else if (s[i] == '0') {
      cnt--;
    } else {
      if (cnt > 0) {
        cnt--;
      } else if (cnt < 0) {
        cnt++;
      } else {
        cnt++;
      }
    }
  }
  cout << (abs(cnt - 0) + 1) << "\n";
  return 0;
}
