#include using namespace std; #define int long long struct moj { int gdzie, dist, last; }; int n; int32_t main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); string s; cin >> s; if( s[0] =='0' ) { cout << -1; return 0; } int pocz = 0; int kon = 0; for( char c : s ) { pocz = pocz*2+c-'0'; n++; kon = kon*2+1; } queue kol; kol.push( {pocz, 0, 0} ); int gdzie, d, l; while( !kol.empty() ) { gdzie = kol.front().gdzie; d = kol.front().dist; l = kol.front().last; kol.pop(); if( kon == gdzie ) { cout << d; return 0; } for( int pom, i=l+1; i<=n; i++ ) { pom = gdzie>>i; pom |= gdzie; kol.push( {pom, d+1, i} ); } } return 0; }