#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 (1000000000000000000 / now < x && i != z - 1) { 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 * i <= n; i++) { if (n % i == 0) { for (long long j = 1; j < 42; j++) { long long l = i, r = 1000000000000000; 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 (1000000000000000000 / (now*i) < r && k != j - 1) { a = false; break; } now *= r; } if (co != n) { a = false; } if (a) { if (ans > r) { ans = r; } } } } if (n % i == 0) { for (long long j = 1; j < 42; j++) { long long l = n / i, r = 1000000000000000 / j; while (r - l > 1) { long long mid = (l + r) / 2; if (solve(mid, n / 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 * (n / i); if (100000000000000000 / (now * (n / i)) < r && k != j - 1) { a = false; break; } now *= r; } if (co != n) { a = false; } if (a) { if (ans > r) { ans = r; } } } } } cout << ans << endl; }