#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int b = 0, c = 0, f = 0;
  char pre = '2';
  for (int i = 0; i < a.size(); i++) {
    if (pre == a[i]) {
      f = 1;
    }
    if (a[i] == '0') {
      b++;
      pre = '0';
    } else {
      c++;
      pre = '1';
    }
  }
  if (f == 0) {
    cout << 0 << endl;
  } else if (b == 0 || c == 0) {
    cout << a.size() << endl;
  } else {
    cout << a.size() - abs(b - c) << endl;
  }
}
