#include using namespace std; int main() { int N; cin >> N; for (int i = 8; i <= N + 1; i++) { int tmp = N; string s; while (tmp) { s += '0' + tmp % i; tmp /= i; } reverse(s.begin(),s.end()); if (s == "17") { cout << i; return 0; } } cout << -1; }