#include "bits/stdc++.h" #define REP(i, n) for(decltype(n) i = 0; i < (n); i++) #define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++) #define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--) #define ALL(a) (a).begin(),(a).end() #define SORT(c) sort((c).begin(),(c).end()) #define DESCSORT(c) sort(c.begin(), c.end(), greater()) #define LL long long int #define LD long double #define PI 3.14159265358979 #define _CRT_SECURE_NO_WARNINGS using namespace std; //================================================ class Radix { private: const char* s; int a[128]; public: Radix(const char* s = "0123456789ABCDEF") : s(s) { int i; for (i = 0; s[i]; ++i) a[(int)s[i]] = i; } std::string to(long long p, int q) { int i; if (!p) return "0"; char t[64] = {}; for (i = 62; p; --i) { t[i] = s[p % q]; p /= q; } return std::string(t + i + 1); } std::string to(const std::string& t, int p, int q) { return to(to(t, p), q); } long long to(const std::string& t, int p) { int i; long long sm = a[(int)t[0]]; for (i = 1; i < (int)t.length(); ++i) sm = sm * p + a[(int)t[i]]; return sm; } }; int main() { ios::sync_with_stdio(false); cin.tie(0); Radix r; int X, ans; cin >> X; for (int i = 2; true; i++) { if (i == 50) { ans = -1; break; } string tmp = r.to(X, i); int aidoru = stoi(tmp); if (aidoru == 17) { ans = i; break; } } cout << ans << "\n"; return 0; }