#include<bits/stdc++.h>
using namespace std;
#define n 100006
vector<int> is_prime(n,true);
    void sieve(){
        is_prime.clear();
        //v2.clear();
    is_prime[0] = is_prime[1] = false;

    for(int i=4;i<=n;i+=2) is_prime[i]=false;
    for (int i = 3; i * i <= n; i+=2) {
        if (is_prime[i]) {
    			//v2.push_back(i);
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }}
    int main()
    { sieve();
    	int X;
    	cin>>X;
    	for(int i=X;i<=100000;i++)
		{
			if(is_prime[i]) {cout<<i<<endl;
			break;}
			else continue;
		}
    }