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

#SP0000010. Số nguyên tố đứng ngay sau N (Prime After N)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Số nguyên tố đứng ngay sau N (Prime After N)

Prime After N

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer NN, find the smallest prime number strictly greater than NN. Even if NN itself is prime, the required answer must be greater than NN.

Input

One line containing the positive integer NN.

Output

Print the smallest prime integer pp satisfying p>Np>N.

Subtasks

  • Subtask 1 (20 points): 1≤N≤10001\le N\le 1000.
  • Subtask 2 (30 points): 1≤N≤10000001\le N\le 1000000.
  • Subtask 3 (50 points): 1≤N≤10000000001\le N\le 1000000000.

Examples

Input

5

Output

7

Explanation

The prime 55 is not eligible because the answer must be strictly greater. 66 is composite and 77 is prime, so the answer is 77.

Input

21

Output

23

Explanation

2222 is an even composite, while 2323 is prime. Therefore the first prime greater than 2121 is 2323.