printРабочее место участника

printЗадачи

2218. Sexy primes

Ограничения: время – 1000ms/2000ms, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

As all good math students know, twin primes are pairs of prime numbers that have a positive difference of 2, whereas cousin primes are pairs of prime numbers that differ by four. Sexy primes are prime numbers that differ from each other by six. The term "sexy primes" stems from the Latin word for six: sex.
You should write the program to find a sexy prime for given prime number.
Input
Input contains one prime number `N` (`2\ ≤\ N\ <\ 10^6`).
Output
Print sexy prime for `N`. If several variants exist, print any of them. If no sexy prime exist, print 0 instead.

Sample Input

29

Sample Output

23
There is no mention of Tim in the problem, but Tim asked to tell you that 1 is not a prime number.
loading