N=int(input ()) i=N-100 e=0 while i<=N+100 and e==0: j=2 while e==0: if i%j==0: print (i) e=1 j+=1 i+=1