#include #include #include using namespace std; typedef uint64_t u64; int det(u64 n, int s){ int min=41,h; int l = __builtin_clzll(~n); //cout << l << endl; if (__builtin_popcountll(n) == s) return 0; for(int i = 1; i <= l; i++) { h = det(((n | n >> i) >> (64 - s)) << (64 - s), s); if (h < min) min = h; if (min == 0) break; } return min + 1; } int main(){ std::ios_base::sync_with_stdio(false); string s; cin >> s; if (s[0] == '0') cout << -1 << '\n'; else { int l = s.size(); bitset<40> bs(s); int n = det(bs.to_ullong() << (64 - l), l); cout << n << '\n'; } }