Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/funksiya-goldbax

Goldbach's conjecture

Medium 1000 ms 128 MB 61%
Share

Write a function Goldbach(n): an even positive integer $n$ can be written as a sum of two primes $n = p + q$; the function returns the smallest such prime $p$.

Example 1: Goldbach(28) → 5 — $28 = 5 + 23$; $28 = 11 + 17$ also works, but $5$ is smaller.

Example 2: Goldbach(4) → 2 — $4 = 2 + 2$.

Write only the function body.

An even number goes into the function Goldbach, which returns the smaller addend of its split into two primes

Input

One line with a positive integer $n$ — the argument of the function.

Output

The value returned by the function: an integer.

Note

$4 \le n \le 10^{7}$
$n$ is even

Examples

Input #1
28
Output #1
5
Input #2
4
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.