#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int cnt1, cnt2, i, u, ans = 0, j;
  cin >> s;
  for (i = 0; i < s.size(); i++) {
    cnt1 = 0;
    cnt2 = 0;
    for (j = 0; j <= i; j++) {
      if (s[j] == '0')
        cnt1++;
      else if (s[j] == '1')
        cnt2++;
    }
    u = abs(cnt1 - cnt2);
    ans = max(u, ans);
  }
  cout << ans << "\n";
  return 0;
}
