def solve():

    from bisect import bisect_right, bisect, bisect_left

    x = int(eval(input()))

    n = 100100

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

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

        if i not in primes:

            i += 1

        else:

            ran = list(range(i * 2, n + 1, i))

            primes.difference_update(ran)

    primes = list(primes)

    y = bisect_left(primes, x)

    print((primes[y]))

    

    

solve()

def solve():

    x = int(eval(input()))



    def is_prime(n):

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

            if n % i == 0:

                return False

        return True



    while not is_prime(x):

        x += 1

    print(x)



solve()

def solve():
    from bisect import bisect_right, bisect, bisect_left

    x = int(eval(input()))
    n = 100100
    primes = set(range(2, n + 1))
    for i in range(2, int(n**0.5 + 1)):
        if i not in primes:
            i += 1
        else:
            ran = list(range(i * 2, n + 1, i))
            primes.difference_update(ran)
    primes = list(primes)
    y = bisect_left(primes, x)
    print((primes[y]))


solve()

def solve():
    x = int(eval(input()))

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

    while not is_prime(x):
        x += 1
    print(x)


solve()

-    from bisect import bisect_right, bisect, bisect_left +    x = int(eval(input())) -    x = int(eval(input())) -    n = 100100 -    primes = set(range(2, n + 1)) -    for i in range(2, int(n**0.5 + 1)): -        if i not in primes: -            i += 1 -        else: -            ran = list(range(i * 2, n + 1, i)) -            primes.difference_update(ran) -    primes = list(primes) -    y = bisect_left(primes, x) -    print((primes[y])) +    def is_prime(n): +        for i in range(2, int(x**0.5) + 1): +            if n % i == 0: +                return False +        return True + +    while not is_prime(x): +        x += 1 +    print(x)