p=[] for i in range(100001,111111,2): for j in range(3,int(i**0.5)+1,2): if i%j==0: break else: p+=[i] if len(p)>5: break pz=[0,1]+sorted([i*j for i in p for j in p if i<=j]) print(pz[int(input())])