n=int(input()) for x in range(n-100,n+101): for i in range(2,x): if x%i==0: print(x) exit()