#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 0 && cnt < 0) {
      cnt++;
      ans++;
    } else if (S[i] == 1 && cnt > 0) {
      cnt--;
      ans++;
    } else {
      if (S[i] == 0) cnt++;
      if (S[i] == 1) cnt--;
    }
  }
  cout << ans << endl;
  return 0;
}
