#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define LL long long
#define out(x) cout << #x << " : " << x << "\n";
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
LL n; cin >> n;
LL k = floor(log10(n)) + 1;
LL p = pow(10, k);
double p2 = 1.0;
for(LL i = 0;i <= 100000000;i++) {
while(p2 >= p) p2 /= 10;
if((LL)(p2) == n) {
cout << i << endl;
return 0;
}
p2 = p2 * 2ll;
}
cout << -1 << endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBNT0QgMTAwMDAwMDAwNwojZGVmaW5lIExMIGxvbmcgbG9uZwojZGVmaW5lIG91dCh4KSBjb3V0IDw8ICN4IDw8ICIgOiAiIDw8IHggPDwgIlxuIjsKCmludCBtYWluKCkgewogICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZShOVUxMKTsKICAgTEwgbjsgY2luID4+IG47CiAgIExMIGsgPSBmbG9vcihsb2cxMChuKSkgKyAxOwogICBMTCBwID0gcG93KDEwLCBrKTsKICAgZG91YmxlIHAyID0gMS4wOwogICBmb3IoTEwgaSA9IDA7aSA8PSAxMDAwMDAwMDA7aSsrKSB7ICAgICAgCiAgICAgIHdoaWxlKHAyID49IHApIHAyIC89IDEwOwogICAgICBpZigoTEwpKHAyKSA9PSBuKSB7CiAgICAgICAgIGNvdXQgPDwgaSA8PCBlbmRsOwogICAgICAgICByZXR1cm4gMDsKICAgICAgfQogICAgICBwMiA9IHAyICogMmxsOwogICB9CiAgIGNvdXQgPDwgLTEgPDwgZW5kbDsKICAgcmV0dXJuIDA7ICAgICAgICAgICAgICAgCn0=