#include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define TRACE(x) cerr << #x << " = " << x << endl #define _ << " _ " << #define pb push_back #define X first #define Y second using namespace std; typedef long long ll; typedef pair pii; int n; string s; bitset<40> all; bool check(int depth, int lower, bitset<40> B){ if (depth == 0){ return (B & all) == all; } if (lower >= n) return false; if (check(depth-1, lower, B | (B << lower))) return true; return check(depth, lower+1, B); } int main(){ ios_base::sync_with_stdio(false); bitset<40> B; cin >> s; n = (int)s.size(); REP(i,n) if (s[i] == '1') B[i] = 1; REP(i,n) all[i] = 1; if (B[0] == 0){ cout << -1 << endl; return 0; } REP(depth,6){ if (check(depth, 1, B)){ cout << depth << endl; return 0; } } cout << 6 << endl; return 0; }