#include <bits/stdc++.h>
using namespace std;
string s;
int a[1000009], m, j, ans;
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  cin >> s;
  m = s[0] - '0';
  for (int i = 0; i < s.size(); i++) {
    if (m != (s[i] - '0')) m = s[i] - '0', j++;
    if (m)
      a[j]++;
    else
      a[j]--;
  }
  for (int i = j; i >= 0; i--) {
    if (a[i] < 0 && i == j)
      ans += abs(a[i]);
    else if (i)
      ans += a[i] + abs(a[i - 1] * 2), i -= 1;
    else if (a[2] != 0 || a[0] != 1)
      ans += a[i] + 1;
  }
  cout << ans;
}
