import sys

from bisect import bisect_left



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def prime_numbers(n):

    if n < 2:

        return []



    m = (n + 1) // 2

    p = [1] * m

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

        if p[i]:

            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)



    a = [2 * i + 1 for i in range(m) if p[i]]

    a[0] = 2

    return a





def main():

    X = int(readline())



    P = prime_numbers(10 ** 6)

    ans = P[bisect_left(P, X)]



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys

from bisect import bisect_left



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def is_prime(n):

    if n == 1:

        return False

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

        if n % i == 0:

            return False

    return True





def main():

    X = int(readline())



    while not is_prime(X):

        X += 1



    print(X)

    return





if __name__ == '__main__':

    main()

import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def prime_numbers(n):
    if n < 2:
        return []
    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n**0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (
                ((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1
            )
    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def main():
    X = int(readline())
    P = prime_numbers(10**6)
    ans = P[bisect_left(P, X)]
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


def main():
    X = int(readline())
    while not is_prime(X):
        X += 1
    print(X)
    return


if __name__ == "__main__":
    main()

-def prime_numbers(n): -    if n < 2: -        return [] -    m = (n + 1) // 2 -    p = [1] * m -    for i in range(1, int((n**0.5 - 1) / 2) + 1): -        if p[i]: -            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * ( -                ((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1 -            ) -    a = [2 * i + 1 for i in range(m) if p[i]] -    a[0] = 2 -    return a +def is_prime(n): +    if n == 1: +        return False +    for i in range(2, int(n**0.5) + 1): +        if n % i == 0: +            return False +    return True -    P = prime_numbers(10**6) -    ans = P[bisect_left(P, X)] -    print(ans) +    while not is_prime(X): +        X += 1 +    print(X)