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

#SP0000007. Số nguyên tố không nhỏ hơn X (Next Prime)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Số nguyên tố không nhỏ hơn X (Next Prime)

Next Prime

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer XX, find the smallest prime number pp satisfying p≥Xp\ge X. No prime number qq may satisfy X≤q<pX\le q<p. If XX is already prime, the answer is XX.

Input

A single line containing the integer XX.

Output

Print one integer pp: the smallest prime number greater than or equal to XX.

Subtasks

  • Subtask 1 (20 points): 2≤X≤10002\le X\le 1000.
  • Subtask 2 (30 points): 2≤X≤200002\le X\le 20000.
  • Subtask 3 (50 points): 2≤X≤1000002\le X\le 100000.

Examples

Input

20

Output

23

Explanation

The values 2020 and 2222 are even, while 21=3⋅721=3\cdot7; none is prime. The next value, 2323, has no divisor between 22 and ⌊23⌋=4\lfloor\sqrt{23}\rfloor=4, so the answer is 2323.

Input

2

Output

2

Explanation

X=2X=2 is prime, so the smallest eligible prime is 22 itself.

Input

99992

Output

100003

Explanation

Every integer in [99992,100002][99992,100002] is composite, and 100003100003 is prime. Hence 100003100003 is the first eligible value.