#include #include #include #include #include using namespace std; typedef long long llint; typedef pair pii; char buff[45]; string tmp; int main(void) { scanf("%s", buff); int sol = 1 << 30; for (int i = 0; i < (1<<20); ++i) { vector V; for (int j = 0; j < 20; ++j) if (i&(1< 6) continue; tmp = buff; for (auto x: V) { auto tmp2 = tmp; for (int j = 0; j < tmp.size(); ++j) { if (j - x >= 0 && tmp[j-x] == '1') tmp2[j] = '1'; } tmp = tmp2; } bool ok = 1; for (int j = 0; j < tmp.size(); ++j) if (tmp[j] == '0') { ok = 0; break; } if (ok) sol = min(sol, (int)V.size()); } if (sol > 50) sol = -1; printf("%d\n", sol); return 0; }