#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long n; bool solve(long long x, long long y, long long z) { long long co = 0; long long now = 1; for (long long i = 0; i < z; i++) { co += now * y; if (100000000000000000 / now < x) { return true; } now *= x; } if (co >= n) { return true; } else { return false; } } int main() { cin >> n; long long ans = 1000000000000007; for (long long i = 1; i <= 9; i++) { for (long long j = 1; j < 40; j++) { long long l = i, r = 2000000000000; while (r - l > 1) { long long mid = (l + r) / 2; if (solve(mid, i, j)) { r = mid; } else { l = mid; } } bool a = true; long long co = 0; long long now = 1; for (long long k = 0; k < j; k++) { co += now * i; if (100000000000000000 / now < r) { a = false; break; } now *= r; } if (co != n) { a = false; } if (a) { if (ans > r) { ans = r; } } } } cout << ans << endl; }