#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int rb;
  long long ans = 0, r = 0, b = 0;
  if (s[0] == '0') {
    rb = 0;
    r++;
  } else {
    rb = 1;
    b++;
  }
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] - '0' == 0) {
      if (rb == 0) {
        r++;
      } else {
        ans += 2;
        b--;
        if (r > 0) {
          rb = 0;
        } else {
          rb = s[i + 1] - '0';
          i++;
          if (rb == 0)
            r++;
          else
            b++;
        }
      }
    } else {
      if (rb == 1) {
        b++;
      } else {
        ans += 2;
        r--;
        if (b > 0) {
          rb = 1;
        } else {
          rb = s[i + 1] - '0';
          i++;
          if (rb == 0)
            r++;
          else
            b++;
        }
      }
    }
  }
  if (r > 0 && b > 0) ans += 2;
  cout << ans << endl;
  return 0;
}
