#K64552. Smallest Sum of Two Primes

    ID: 32000 Type: Default 1000ms 256MiB

Smallest Sum of Two Primes

Smallest Sum of Two Primes

Given an integer \(T\), your task is to find the smallest integer \(S\) such that \(S \ge T\) and \(S\) can be expressed as the sum of two prime numbers. In other words, find the minimum \(S \ge T\) for which there exist prime numbers \(p\) and \(q\) satisfying \(S = p + q\). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.

For example, for \(T = 10\), since \(10 = 3 + 7\) (and both 3 and 7 are prime), the answer is 10. If no such representation exists for a given \(T\), you must check the next integer, until a valid representation is found.

The mathematical condition to check is:

[ \exists, p, q ;\text{prime} \quad \text{such that} \quad S = p + q \quad \text{and} \quad S \ge T. ]

inputFormat

The input consists of a single integer \(T\) (\(1 \le T \le 10^6\)), which is read from standard input.

outputFormat

Output a single integer \(S\), the smallest number greater than or equal to \(T\) that can be represented as the sum of two prime numbers. Print the answer to standard output.

## sample
10
10