#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, x, kari = 0, count = 0;
  long long ans = 0;
  int N = 10, S = 10, E = 10, W = 10;
  string ST_Array;
  cin >> ST_Array;
  for (int i = 0; i < ST_Array.length(); i++) {
    if (ST_Array[i]) {
      a++;
    } else if (a > 0)
      a--;
    else
      ans++;
  }
  cout << ans << endl;
}
