#include<bits/stdc++.h>
using namespace std;
unsigned long n;
int Prime(unsigned long a);
int main()
{
cin >> n;
while(Prime(n+1)==0)
n++;
cout << n+1;
}
int Prime(unsigned long a)
{
unsigned long i;
if (a == 2)
return 1;
if (a == 0 || a == 1 || a % 2 == 0)
return 0;
for(i = 3; i*i <= a && a % i; i += 2)
;
return i*i > a;
}