P=range(9**6) for d in P[2:]:P[d+d::d]=[0]*(531440/d-1) P=filter(None,P) while 1:print P[input()]