#include <bits/stdc++.h>
using ll = long long;
using namespace std;
string s;
void input() { cin >> s; }
void solver() {
  ll cnt = 0;
  ll tmp = 0;
  ll ans = s.length();
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '0') {
      cnt++;
      tmp++;
    } else {
      cnt--;
      tmp++;
    }
    if (cnt == 0) {
      ans -= tmp;
      cnt = 0;
      tmp = 0;
    }
  }
  cout << s.length() - ans << endl;
}
int main() {
  input();
  solver();
}
