#include #include #include using namespace std; int main(){ string s; cin >> s; const int sz = s.length(); string pr(sz,'1'); bitset<40> b1(s); bitset<40> b2(s); bitset<40> pare(pr); if(s[0] == '0'){ cout << -1 << endl; } else{ int res = 0; int l1 = sz - 1; while(b1 != pare){ for(int i=l1;i>=0;i--){ if(!b1[i]){ l1 = i; break; } } res+=1; int l = sz-1-l1; b1 >>= l; b1 |= b2; b2 = b1; //cout << b1.to_string() << endl; } cout << res << endl; } return 0; }