#include using namespace std; #define pb push_back #define sqr(x) ((x) * (x)) #define fi first #define se second typedef pair ii; const int OO = 1e9 + 7; int Exp2(int a) { int res = 1; for (int i = 0; i < a; i++) res *= 2; return res; } void Inp() { string s; cin >> s; vector n; int smallest = 40; int round = 0; if (s[0] == '0') { cout << -1 << endl; } for (char c : s) { if (c == '1') { round += 1; n.push_back(1); } else if (c == '0') { if (round < smallest) { smallest = round; } n.push_back(0); } } int start = (int)log2(smallest); int steps = Exp2(start); //cout << steps << endl; int ret = 0; while (count(n.begin(), n.end(), 1) != n.size()) { ret += 1; vector m = n; //cout << count(n.begin(), n.end(), 1) << endl; for (int i = 0; i < n.size() - steps; i++) { m[i + steps] = max(n[i], n[i + steps]); } n = m; steps *= 2; } cout << ret << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); Inp(); return 0; }