import strutils proc prime(n: int): seq[int] = let gaps: array[-2..8, int] = [1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6] var m: int = n p: int = 2 ind: int = -2 ret: seq[int] while p * p <= m: while m mod p == 0: ret.add(p) m = m div p p += gaps[ind mod 9] ind.inc if m > 1: ret.add(m) return ret let n: int = stdin.readline.parseInt var ans: int for i in (n - 100)..(n + 100): if prime(i).len > 1: ans = i break echo ans