x = int(eval(input()))



def is_prime(n):

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

		if n % i == 0:

			return False

	return n != 1 # 1のときは例外





while True:

	if is_prime(x):

		print(x)

		break

	x += 1
x = int(eval(input()))



# 素数

n = 10 ** 5 + 1000

primes = [True] * (n + 1)

p = 2

while p * p <= n:

    if primes[p]:

        for i in range(p * p, n + 1, p): # p*pスタートでいいのか

            primes[i] = False

    p += 1



primes[0], primes[1] = False, False



while True:

    if primes[x]:

        print(x)

        exit()

    x += 1
x = int(eval(input()))


def is_prime(n):
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return n != 1  # 1のときは例外


while True:
    if is_prime(x):
        print(x)
        break
    x += 1

x = int(eval(input()))
# 素数
n = 10**5 + 1000
primes = [True] * (n + 1)
p = 2
while p * p <= n:
    if primes[p]:
        for i in range(p * p, n + 1, p):  # p*pスタートでいいのか
            primes[i] = False
    p += 1
primes[0], primes[1] = False, False
while True:
    if primes[x]:
        print(x)
        exit()
    x += 1

- - -def is_prime(n): -    for i in range(2, int(n**0.5) + 1): -        if n % i == 0: -            return False -    return n != 1  # 1のときは例外 - - +# 素数 +n = 10**5 + 1000 +primes = [True] * (n + 1) +p = 2 +while p * p <= n: +    if primes[p]: +        for i in range(p * p, n + 1, p):  # p*pスタートでいいのか +            primes[i] = False +    p += 1 +primes[0], primes[1] = False, False -    if is_prime(x): +    if primes[x]: -        break +        exit()