//https://ncode.syosetu.com/n4830bu/312/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    for (ll i = 3; i * i <= N; i++) {
        if (N % i == 0) {
            cout << i << endl;
            return 0;
        }
    }
    cout << N << endl;
}