n = int(input()) i = 3 if n % 2 == 0: print(4) exit() while True: if n % i == 0: print(i) break i += 2