#include <bits/stdc++.h>
using namespace std;
struct sub {
  long long l;
  long long r;
};
bool checkIfSingleZero(const string &s, long long ind) {
  return ((s[ind - 1] == '1') && (s[ind + 1] == '1'));
}
long long findR(const string &s, long long ind) {
  long long sz = s.size();
  sz -= 1;
  long long i = ind;
  for (; i < sz; ++i) {
    if (s[i] == '1') {
      continue;
    }
    if ((s[i] == '0') && (s[i + 1] == '1')) {
      continue;
    }
    break;
  }
  return i;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  cin >> s;
  long long szit = s.size();
  long long lastOne = szit - 1;
  for (long long i = szit - 1; i >= 0; --i) {
    if (s[i] == '1') {
      lastOne = i;
      break;
    }
  }
  string t = s.substr(0, lastOne + 1);
  s = t;
  long long sz = s.size();
  long long sz0 = sz;
  s += '1';
  vector<long long> ones(sz + 2, 0), zeroes(sz + 2, 0);
  vector<sub> singleZeroes;
  long long leftMostOne = 0;
  for (long long i = 1; i < sz;) {
    if (s[i] == '0') {
      if (checkIfSingleZero(s, i)) {
        sub obj;
        obj.l = leftMostOne + 1;
        obj.r = findR(s, i + 1);
        singleZeroes.push_back(obj);
        i = obj.r;
      } else {
        ++i;
      }
    } else {
      if (s[i - 1] != '1') {
        leftMostOne = i;
      }
      ++i;
    }
  }
  if (singleZeroes.size() > 1) {
    long long itx = 0;
    for (long long i = 0; i < sz;) {
      if (singleZeroes[itx].l == (i + 1)) {
        i = singleZeroes[itx].r;
        ++itx;
        continue;
      }
      if (s[i] == '1') {
        long long cnt = 0, st = i, en = i;
        while ((i < sz) && (s[i] == '1')) {
          en = i;
          ++i;
          ++cnt;
        }
        if (cnt > 1) {
          for (long long it = st; it <= en; ++it) {
            s[it] = '0';
          }
          s[st] = '1';
          s[en] = '1';
        }
      } else {
        ++i;
      }
    }
  }
  for (long long i = 1; i <= sz; ++i) {
    if (s[i - 1] == '1') {
      ones[i] = 1;
    } else {
      zeroes[i] = 1;
    }
    ones[i] += ones[i - 1];
    zeroes[i] += zeroes[i - 1];
  }
  ones[sz + 1] += ones[sz];
  zeroes[sz + 1] += zeroes[sz];
  long long l = 0, r = 0;
  long long ans = 0;
  sz = singleZeroes.size();
  for (long long i = 0; i < sz; ++i) {
    long long l0 = singleZeroes[i].l - 1, r0 = singleZeroes[i].r;
    if (l0 != 0) {
      r = l0;
    }
    ans += min(zeroes[r0] - zeroes[l0] + 2, ones[r0] - ones[l0]);
    ans += (ones[r] - ones[l]);
    l = r0;
    if ((i == (sz - 1)) && (r0 < sz0)) {
      ans += (ones[sz0] - ones[r0]);
    }
  }
  if (sz == 0) {
    ans = min(ones[sz0], zeroes[sz0] + 2);
  }
  cout << ans;
  return 0;
}
