import math as m n=input() print next(iter(i for i in range(3,10**7)if n%i<1),0)or n