N=int(input()) for i in range(N-100,N+101): if i<=2: pass else: memo=0 for j in range(2,i): if i%j==0: memo+=1 break if memo==1: print(i) break