#include using namespace std; typedef long long ll; int main(){ string S; cin >> S; int N= (int) S.size(); int head = 0; int tail = 0; string T = ""; while( head < N){ if( S[head] == '0'){ head++; tail++; T += '0';} else{ while( tail < N && S[tail] == '1'){ tail++;} T += '1'; head = tail;} } N = (int) T.size(); head = 0; tail = 0; string U = ""; int cnt = 0; while( head < N){ int res = 0; if( T[head] == '1'){ head++; tail++; U += '1';} else{ while( tail < N && T[tail] == '0'){ res++; tail++;} if( res > 1){ U += '0';} else{ cnt++;} } head = tail; } head = 0; tail = 0; N = (int) U.size(); while( head < N){ if( U[tail] == '0'){ head++; tail++;} else{ while( tail < N && U[tail] == '1'){ tail++;} cnt+= 2;} head = tail; } cout << cnt << endl; return 0;}