import math as m
n=input()
print next(iter(i for i in range(3,2**20)if n%i<1),0)or(-~n%2)*n/2or n