def f(x): c = 1 while c < x//2: c += 1 if x % c == 0 : return 1 return 0 N = int(input()) print([x for x in range(N-100, N+101) if f(x)][0])