#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
int main(void) {
  string s;
  cin >> s;
  Int length = (Int)s.length();
  Int result = length;
  Int start = 0;
  Int end = length - 1;
  for (Int i = 0; i < length; ++i) {
    if (s[i] == '1') {
      result--;
      start++;
    } else {
      break;
    }
  }
  for (Int i = length - 1; i >= 0; --i) {
    if (s[i] == '0') {
      result--;
      end--;
    } else {
      break;
    }
  }
  s = s.substr(start, end - start + 1);
  Int count = 0;
  for (Int i = 0; i < (Int)s.length(); ++i) {
    if (s[i] == '0') {
      count--;
    } else {
      count++;
    }
  }
  if (count < 0) {
    count *= (-1);
  }
  result -= count;
  cout << result << endl;
  return 0;
}
