p=[100003,100019,100043,100049,100057,100069] u=[0,1]+sorted(set(x*y for x in p for y in p)) print(u[int(input())])