import sys

import bisect

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(500000)



n = int(read())

n_ = 5*10**5



primes = set(range(2, n_+1))

for i in range(2, int(n_**0.5+1)):

    primes.difference_update(list(range(i*2, n_+1, i)))

primes=list(primes)



idx = bisect.bisect_left(primes, n)







print((primes[idx]))

import sys

import math

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(500000)



n = int(read())



def is_prime(n):

    if n == 1: return False



    for k in range(2, int(math.sqrt(n)) + 1):

        if n % k == 0:

            return False



    return True





for i in range(n, n*n, 1):

    if is_prime(i):

        print(i)

        break

import sys
import bisect

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())
n_ = 5 * 10**5
primes = set(range(2, n_ + 1))
for i in range(2, int(n_**0.5 + 1)):
    primes.difference_update(list(range(i * 2, n_ + 1, i)))
primes = list(primes)
idx = bisect.bisect_left(primes, n)
print((primes[idx]))

import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)
n = int(read())


def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True


for i in range(n, n * n, 1):
    if is_prime(i):
        print(i)
        break

-import bisect +import math -n_ = 5 * 10**5 -primes = set(range(2, n_ + 1)) -for i in range(2, int(n_**0.5 + 1)): -    primes.difference_update(list(range(i * 2, n_ + 1, i))) -primes = list(primes) -idx = bisect.bisect_left(primes, n) -print((primes[idx])) + + +def is_prime(n): +    if n == 1: +        return False +    for k in range(2, int(math.sqrt(n)) + 1): +        if n % k == 0: +            return False +    return True + + +for i in range(n, n * n, 1): +    if is_prime(i): +        print(i) +        break