N = int(input()) for i in range(N-100, N+100): if pow(2, i-1) % i != 1 and i != 1 and i != 2: print(i) exit()