import sys

#import numpy as np

stdin = sys.stdin



ri = lambda: int(rs())

rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only

rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces



X = ri()

def primes(n):

    is_prime = [True] * (n + 1)

    is_prime[0] = False

    is_prime[1] = False

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

        if not is_prime[i]:

            continue

        for j in range(i * 2, n + 1, i):

            is_prime[j] = False

    return [i for i in range(n + 1) if is_prime[i]]



l = set(primes(10**6))



while True:

    if X in l:

        print(X)

        exit()

    X += 1
import sys

sys.setrecursionlimit(10 ** 7)



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



X = ir()



def check(n):

    if X == 2:

        return True

    if n % 2 == 0:

        return False

    f = 3

    while f * f <= n:

        if n % f == 0:

            return False

        else:

            f += 2

    return True



while True:

    if check(X):

        print(X); exit()

    else:

        X += 1



# 44
import sys

# import numpy as np
stdin = sys.stdin
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces
X = ri()


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


l = set(primes(10**6))
while True:
    if X in l:
        print(X)
        exit()
    X += 1

import sys

sys.setrecursionlimit(10**7)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
X = ir()


def check(n):
    if X == 2:
        return True
    if n % 2 == 0:
        return False
    f = 3
    while f * f <= n:
        if n % f == 0:
            return False
        else:
            f += 2
    return True


while True:
    if check(X):
        print(X)
        exit()
    else:
        X += 1
# 44

-# import numpy as np -stdin = sys.stdin -ri = lambda: int(rs()) -rl = lambda: list(map(int, stdin.readline().split()))  # applies to numbers only -rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces -X = ri() +sys.setrecursionlimit(10**7) +sr = lambda: sys.stdin.readline().rstrip() +ir = lambda: int(sr()) +lr = lambda: list(map(int, sr().split())) +X = ir() -def primes(n): -    is_prime = [True] * (n + 1) -    is_prime[0] = False -    is_prime[1] = False -    for i in range(2, int(n**0.5) + 1): -        if not is_prime[i]: -            continue -        for j in range(i * 2, n + 1, i): -            is_prime[j] = False -    return [i for i in range(n + 1) if is_prime[i]] +def check(n): +    if X == 2: +        return True +    if n % 2 == 0: +        return False +    f = 3 +    while f * f <= n: +        if n % f == 0: +            return False +        else: +            f += 2 +    return True -l = set(primes(10**6)) -    if X in l: +    if check(X): -    X += 1 +    else: +        X += 1 +# 44