maxA = 10**6



X = int(eval(input()))



def getIsPrimes(n):

    isPrimes = [False]*2 + [True]*(n-1)

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

        isPrimes[x] = False

    for d in range(3, int(n**0.5)+1):

        if isPrimes[d]:

            for x in range(d*d, n+1, d):

                isPrimes[x] = False

    return isPrimes



isPrimes = getIsPrimes(maxA)



for i in range(X, maxA+1):

    if isPrimes[i]:

        print(i)

        break



maxA = 10**5 + 3



X = int(eval(input()))



def isPrime(x):

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

        if x%d == 0:

            return False

    return x != 1



for i in range(X, maxA+1):

    if isPrime(i):

        print(i)

        break

maxA = 10**6
X = int(eval(input()))


def getIsPrimes(n):
    isPrimes = [False] * 2 + [True] * (n - 1)
    for x in range(2 * 2, n + 1, 2):
        isPrimes[x] = False
    for d in range(3, int(n**0.5) + 1):
        if isPrimes[d]:
            for x in range(d * d, n + 1, d):
                isPrimes[x] = False
    return isPrimes


isPrimes = getIsPrimes(maxA)
for i in range(X, maxA + 1):
    if isPrimes[i]:
        print(i)
        break

maxA = 10**5 + 3
X = int(eval(input()))


def isPrime(x):
    for d in range(2, int(x**0.5) + 1):
        if x % d == 0:
            return False
    return x != 1


for i in range(X, maxA + 1):
    if isPrime(i):
        print(i)
        break

-maxA = 10**6 +maxA = 10**5 + 3 -def getIsPrimes(n): -    isPrimes = [False] * 2 + [True] * (n - 1) -    for x in range(2 * 2, n + 1, 2): -        isPrimes[x] = False -    for d in range(3, int(n**0.5) + 1): -        if isPrimes[d]: -            for x in range(d * d, n + 1, d): -                isPrimes[x] = False -    return isPrimes +def isPrime(x): +    for d in range(2, int(x**0.5) + 1): +        if x % d == 0: +            return False +    return x != 1 -isPrimes = getIsPrimes(maxA) -    if isPrimes[i]: +    if isPrime(i):