import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) mod=10**9+7 def main(): #nまでの素数を列挙(n loglogn) N=I() n = 3*(10**5) #is_prime[i]にはi-1が素数か否かを示すboolが入る,[0]に1の素数判定がある. is_prime = [True]*(n+1) is_prime[0] = False for i in range(2, n+1): if is_prime[i-1]: j = 2 * i while j <= n: is_prime[j-1] = False j += i table=[] for i in range(10**5,n): if is_prime[i]: table.append(i+1) if len(table)>=100: break ans=[1] M=len(table) for i in range(M): for j in range(M): ans.append(table[i]*table[j]) ans.sort() print(ans[N-1]) main()