#!/usr/bin/env python3



def main():

    x = int(eval(input()))

    primes = furui(300000)

    for p in primes:

        if x <= p:

            print(p)

            return

    raise ValueError



# https://mathtrain.jp/eratosthenes

def furui(nmax):

    assert nmax > 2

    p = 2

    primes = list(range(2, nmax + 1))

    while True:

        if p ** 2 > nmax:

            break

        primes_next = []

        for x in primes:

            if x <= p or x % p != 0:

                primes_next.append(x)

        primes = primes_next

        p = primes[primes.index(p) + 1]

    return primes



if __name__ == "__main__":

    main()

#!/usr/bin/env python3



def main():

    x = int(eval(input()))

    primes = sieve(300000)

    for p in primes:

        if x <= p:

            print(p)

            return

    raise ValueError



# O(nloglogn) https://mathtrain.jp/eratosthenes

def sieve(n):  # exclusive

    s = [True] * n

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

        if s[x]:

            for i in range(2 * x, n, x):

                s[i] = False

    return [i for i in range(2, n) if s[i]]



if __name__ == "__main__":

    main()

#!/usr/bin/env python3
def main():
    x = int(eval(input()))
    primes = furui(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError


# https://mathtrain.jp/eratosthenes
def furui(nmax):
    assert nmax > 2
    p = 2
    primes = list(range(2, nmax + 1))
    while True:
        if p**2 > nmax:
            break
        primes_next = []
        for x in primes:
            if x <= p or x % p != 0:
                primes_next.append(x)
        primes = primes_next
        p = primes[primes.index(p) + 1]
    return primes


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
def main():
    x = int(eval(input()))
    primes = sieve(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError


# O(nloglogn) https://mathtrain.jp/eratosthenes
def sieve(n):  # exclusive
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]:
            for i in range(2 * x, n, x):
                s[i] = False
    return [i for i in range(2, n) if s[i]]


if __name__ == "__main__":
    main()

-    primes = furui(300000) +    primes = sieve(300000) -# https://mathtrain.jp/eratosthenes -def furui(nmax): -    assert nmax > 2 -    p = 2 -    primes = list(range(2, nmax + 1)) -    while True: -        if p**2 > nmax: -            break -        primes_next = [] -        for x in primes: -            if x <= p or x % p != 0: -                primes_next.append(x) -        primes = primes_next -        p = primes[primes.index(p) + 1] -    return primes +# O(nloglogn) https://mathtrain.jp/eratosthenes +def sieve(n):  # exclusive +    s = [True] * n +    for x in range(2, int(n**0.5) + 1): +        if s[x]: +            for i in range(2 * x, n, x): +                s[i] = False +    return [i for i in range(2, n) if s[i]]