def is_prime(q): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False return pow(2, q-1, q) == 1 N = int(input()) for i in range(N-100, N+100+1): if i == 1: continue if not is_prime(i): print(i) break