#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define LL long long
#define out(x) cout << #x << " : " << x << "\n";
int firstKdigit(int p, int k) {
double lg = p * log10(2) / log10(10);
double f = lg - floor(lg) + k - 1;
return pow(10, f);
}
int main() {
int n; cin >> n;
int k = log10(n) + 1;
bool ok = false;
for(int i = 0;i <= 100000000;i++) {
int fk = firstKdigit(i, k);
//cout << fk << " ";
if(fk == n) {
cout << i << "\n";
ok = true;
break;
}
}
if(!ok) cout << -1;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBNT0QgMTAwMDAwMDAwNwojZGVmaW5lIExMIGxvbmcgbG9uZwojZGVmaW5lIG91dCh4KSBjb3V0IDw8ICN4IDw8ICIgOiAiIDw8IHggPDwgIlxuIjsKCmludCBmaXJzdEtkaWdpdChpbnQgcCwgaW50IGspIHsKICAgZG91YmxlIGxnID0gcCAqIGxvZzEwKDIpIC8gbG9nMTAoMTApOwogICBkb3VibGUgZiA9IGxnIC0gZmxvb3IobGcpICsgayAtIDE7CiAgIHJldHVybiBwb3coMTAsIGYpOyAgCn0KCmludCBtYWluKCkgewogICBpbnQgbjsgY2luID4+IG47CiAgIGludCBrID0gbG9nMTAobikgKyAxOwogICBib29sIG9rID0gZmFsc2U7CiAgIGZvcihpbnQgaSA9IDA7aSA8PSAxMDAwMDAwMDA7aSsrKSB7CiAgICAgIGludCBmayA9IGZpcnN0S2RpZ2l0KGksIGspOwogICAgICAvL2NvdXQgPDwgZmsgPDwgIiAiOwogICAgICBpZihmayA9PSBuKSB7CiAgICAgICAgIGNvdXQgPDwgaSA8PCAiXG4iOwogICAgICAgICBvayA9IHRydWU7CiAgICAgICAgIGJyZWFrOwogICAgICB9CiAgIH0KICAgaWYoIW9rKSBjb3V0IDw8IC0xOwogICByZXR1cm4gMDsgICAgICAgICAgICAgICAKfQogICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA=