#include<iostream>
using namespace std;
int main()
{
long n,i,j,*nn;
for(;;){
cin>>n;
if(cin.eof())break;
nn=new long [n+1];
nn[1]=0;nn[2]=1;
for(i=3;i<=n;i+=2)nn[i]=1;
for(i=4;i<=n;i+=2)nn[i]=0;
for(i=3;i<=n;i+=2){
for(j=i;j*j<=n;j+=2){
if(i%j==0){nn[i]=0;break;}
}
}
cout<<j<<endl;
delete [] nn;
}
return 0;
}