#include using namespace std; typedef long long ll; int diff(string a, string b){ //2進数表示で、aからbの引き算してから、結果に含まれる1の個数を調べる deque q; int pa = (int)a.size()-1; int pb = (int)b.size()-1; int k = 0; //k == 1で、すでに借りがある状態。なければ0. for(int i = 0; i < pa-pb; i++){ b = "0" + b;} //桁を揃える int p = pa; while( p >= 0){ if( k == 0){ if( a[p] == '0' && b[p] == '0'){ q.push_front('0');} if( a[p] == '0' && b[p] == '1'){ q.push_front('1'); k = 1;} if( a[p] == '1' && b[p] == '0'){ q.push_front('1');} if( a[p] == '1' && b[p] == '1'){ q.push_front('0');} } else{//借りを残している場合 if( a[p] == '0' && b[p] == '0'){ q.push_front('1');}//まだ借りは残る if( a[p] == '0' && b[p] == '1'){ q.push_front('0');} if( a[p] == '1' && b[p] == '0'){ q.push_front('0'); k = 0;} if( a[p] == '1' && b[p] == '1'){ q.push_front('1');} } p--; } int cnt = 0; for(int i = 0; i < (int) q.size(); i++){ if(q[i] == '1'){ cnt++;}} return cnt; } int main(){ string S; cin >> S; int N = (int) S.size(); string M = "1"; string m = "1"; for(int i = 0; i < N; i++){ M += "0";} for(int i = 0; i < N-1; i++){ m += "0";} int res1 = diff(M,S); int res2 = diff(S,m); cout << min(res1,res2)+1 << endl; return 0;}