#Python 3.X
from itertools import count
def prime(n):
for i in range(2, (n // 2) + 1):
if n % i == 0:
return False
else:
return True
def prime_closest_to(n):
for i in count(n):
if prime(i):
x = i
dx = x - n
break
for j in count(n - 1, 1):
if prime(j):
y = j
dy = n - y
break
ret = x if dx < dy else y
return ret
n = int(input('n = '))
print('Ближайшее простое число =', prime_closest_to(n))