#include #include #include #include #include #include #include using namespace std; using LL = long long; int b; LL goal; int mindepth; void megold( LL szam, int depth) { if (depth >= mindepth) return; if ( (szam & goal) == goal) { mindepth = depth; return; } for (int i = 1; i <= b/2; i++){ //cout << "eltol " << i << "-vel "; //printf("%x %x\n", szam, (szam<>s; if (s[0] == '0') { cout << -1 << endl; return 0; } b = s.length(); goal = (1LL<<(b)) -1; //cout << "goal: " << goal << endl; mindepth = ceil( log2( b ) ); //cout << " min: " << mindepth << endl; LL num = 0; for (int i = 0; i < b; i++){ num |= (LL(s[i]-'0') << i); } //cout << "num: " << num << endl; megold(num, 0); cout << mindepth << endl; return 0; }