#include using namespace std; typedef long long ll; const int maxn = 50; char B[maxn]; int main() { scanf("%s", B); int len = strlen(B); ll x = 0; for(int i = 0; i < len; ++i) { x *= 2; if(B[i] == '1') x += 1; } if(x == 0) { puts("-1"); return 0; } int res = 1000; for(int i = 0; i < (1 << 21); ++i) { ll y = x; int d = 0; for(int j = 0; j < 25; ++j) { if(i & (1 << j)) { y |= y >> (j + 1); ++d; } } if(y + 1 == (1ll << len)) res = min(res, d); } if(res == 1000) { puts("-1"); return 0; } printf("%d\n", res); }