#include using namespace std; using ll = long long; bool is_prime(ll n) { for (ll i = 2; i * i <= n; ++i) { if (n % i == 0) return false; } return true; } int main() { ll n; cin >> n; for (ll i = 3; i * i <= n; ++i) { if (n % i == 0) { cout << i << endl; return 0; } } ll a = n; if (a % 2 == 0 && a > 4) a /= 2; if (a % 2 == 0 && (a == 6 || a == 8 || (a < 4 && is_prime(a/2)))) a /= 2; cout << a << endl; }