#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long n; int main() { cin >> n; for (long long j = 2; j <= 1000000; j++) { long long co = 0; long long now = 1; while (co <= n) { co += now; if (n % co == 0 && n / co < co) { cout << j << endl; return 0; } if (1000000000000 / now < j) { break; } now *= j; } } long long ans = 1000000000000000; for (long long i = 1; i * i <= n; i++) { if (n % i == 0 && n / i - 1 > i) { if (ans > n / i - 1) { ans = n / i - 1; } } } cout << ans << endl; }