# coding: utf-8 import math N = int(input()) num = 3 while True: if N % num == 0: break if num > math.sqrt(N): num = N break num += 1 print(num)