import math N = int(input()) min = N-100 max = N+100 min_s = math.sqrt(min) if min != 2 and min % 2 == 0: print(min) elif min == 2 or min == 1: print(4) elif min % 2 == 1: for i in range(3, min, 2): if i > min_s: ans = min + 1 break elif min % i != 0: continue elif min % i == 0: ans = min break print(ans)