PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000077. Số may mắn có ba ước nguyên tố (Distinct Primes)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Số may mắn có ba ước nguyên tố (Distinct Primes)

Distinct Primes

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer is called lucky when it has at least three distinct prime divisors. For instance, 30=2⋅3⋅530=2\cdot3\cdot5 and 42=2⋅3⋅742=2\cdot3\cdot7 are the two smallest lucky numbers. Sort all lucky numbers increasingly as b1,b2,…b_1,b_2,\ldots. Given nn, find the element at 1-based position nn.

Input

One line contains the integer nn.

Output

Print the nn-th lucky number.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30.
  • Subtask 2 (30 points): 1≤n≤2001\le n\le 200.
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000.

Examples

Input

2

Output

42

Explanation

The smallest positive integer with at least three distinct prime divisors is 30=2⋅3⋅530=2\cdot3\cdot5. The next is 42=2⋅3⋅742=2\cdot3\cdot7. Since n=2n=2, output 42.