#include #include #include long long f(long long N) { long long n, m, mod; for (n = 3; (N / n) > 2; n += mod) { mod = N % n; if (mod == 0) { return n; } } for (m = n; (N / m) > 1; m += n) { if ((N % (m + mod)) == 0) { return (m + mod); } } return N; } int main() { long long N; std::cin >> N; std::cout << f(N) << std::endl; return 0; }