n = int(input()) l = max(2, n-100) r = n+100 def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors for i in range(l, r+1): d = make_divisors(i) if len(d) > 2: print(i) exit()