def c_next_prime():

    from bisect import bisect_left

    X = int(eval(input()))



    def prime_table(n):

        """n以下の素数のリスト(エラトステネスの篩)"""

        is_prime = [True] * (n + 1)

        is_prime[0] = is_prime[1] = False  # 0と1は素数でない

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

            if not is_prime[j]:

                continue

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

                is_prime[k] = False  # jの倍数は素数でない

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



    primes = prime_table(2 * X)

    return primes[bisect_left(primes, X)]



print((c_next_prime()))
def c_next_prime():

    from bisect import bisect_left

    X = int(eval(input()))



    def prime_table(n):

        """n以下の素数のリスト(エラトステネスの篩)"""

        is_prime = [True] * (n + 1)

        is_prime[0] = is_prime[1] = False  # 0と1は素数でない

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

            if not is_prime[j]:

                continue

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

                is_prime[k] = False  # jの倍数は素数でない

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



    primes = prime_table(min(2 * X, 10**5 + 3))

    return primes[bisect_left(primes, X)]



print((c_next_prime()))
def c_next_prime():
    from bisect import bisect_left

    X = int(eval(input()))

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    primes = prime_table(2 * X)
    return primes[bisect_left(primes, X)]


print((c_next_prime()))

def c_next_prime():
    from bisect import bisect_left

    X = int(eval(input()))

    def prime_table(n):
        """n以下の素数のリスト(エラトステネスの篩)"""
        is_prime = [True] * (n + 1)
        is_prime[0] = is_prime[1] = False  # 0と1は素数でない
        for j in range(2, int(n**0.5) + 1):
            if not is_prime[j]:
                continue
            for k in range(j * 2, n + 1, j):
                is_prime[k] = False  # jの倍数は素数でない
        return [i for i in range(n + 1) if is_prime[i]]

    primes = prime_table(min(2 * X, 10**5 + 3))
    return primes[bisect_left(primes, X)]


print((c_next_prime()))

-    primes = prime_table(2 * X) +    primes = prime_table(min(2 * X, 10**5 + 3))