#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { return MUL(x, POW(y, MOD - 2)); }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
bool done[100010];
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int ans = 0;
  string s;
  int n_one = 0, n_zero = 0;
  cin >> s;
  bool one = (s[0] == '1' ? true : false);
  n_one = (s[0] == '1' ? 1 : 0);
  n_zero = (s[0] == '0' ? 1 : 0);
  for (int i = (int)(1); i < (int)(s.size()); ++i) {
    if (one && s[i] == '1') {
      n_one++;
    }
    if (one && s[i] == '0') {
      n_zero++;
      if (n_zero > 0 && !done[i - 1] && !done[i]) {
        ans += 2;
        n_zero--;
        n_one--;
        done[i - 1] = true;
        done[i] = true;
      }
      one = false;
    }
    if (!one && s[i] == '1') {
      n_one++;
      if (n_one > 0 && !done[i - 1] && !done[i]) {
        ans += 2;
        n_zero--;
        n_one--;
        done[i - 1] = true;
        done[i] = true;
      }
      one = true;
    }
    if (!one && s[i] == '0') {
      n_zero++;
    }
  }
  if (n_zero > 0 && n_one > 0) {
    ans += 2;
  }
  cout << ans << endl;
  return 0;
}
