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

#SP0000140. Số nhỏ nhất có các ước cách xa nhau (Different Divisors)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Số nhỏ nhất có các ước cách xa nhau (Different Divisors)

Different Divisors

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a positive integer dd. Find the smallest positive integer aa satisfying both conditions:

  • aa has at least four distinct positive divisors;
  • the absolute difference between any two distinct positive divisors of aa is at least dd.

For example, with d=2d=2, the number 1212 is invalid because it has divisors 22 and 33 differing by 11.

Input

One line contains the integer dd.

Output

Print the smallest positive integer aa satisfying both conditions.

Subtasks

  • Subtask 1 (20 points): 1≤d≤1001\le d\le100.
  • Subtask 2 (30 points): 1≤d≤10001\le d\le1000.
  • Subtask 3 (50 points): 1≤d≤100001\le d\le10000.

Examples

Input

2

Output

15

Explanation

For d=2d=2, the positive divisors of 1515 are 1,3,5,151,3,5,15. Their consecutive differences are 2,2,102,2,10, all at least 22. Thus all divisor pairs satisfy the condition. No smaller positive integer with at least four divisors does so, hence the output is 15.