x = int(eval(input()))

y = x + 100

is_prime = [False] * 2 + [True for _ in range(2, y+1)]

prime = []

for i in range(2, y+1):

	for j in range(i*2, y+1, i):

		is_prime[j] = False

for i in range(y+1):

	if is_prime[i]:

		prime.append(i)

for i in range(len(prime)):

  if prime[i] >= x:

    print((prime[i]))

    break

  else:

    continue
x = int(eval(input()))

while True:

  x_sqrt = int(x ** 0.5)

  for i in range(2, x_sqrt+1):

    if x % i == 0:

      break

  else:

    print(x)

    break

  x += 1
x = int(eval(input()))
y = x + 100
is_prime = [False] * 2 + [True for _ in range(2, y + 1)]
prime = []
for i in range(2, y + 1):
    for j in range(i * 2, y + 1, i):
        is_prime[j] = False
for i in range(y + 1):
    if is_prime[i]:
        prime.append(i)
for i in range(len(prime)):
    if prime[i] >= x:
        print((prime[i]))
        break
    else:
        continue

x = int(eval(input()))
while True:
    x_sqrt = int(x**0.5)
    for i in range(2, x_sqrt + 1):
        if x % i == 0:
            break
    else:
        print(x)
        break
    x += 1

-y = x + 100 -is_prime = [False] * 2 + [True for _ in range(2, y + 1)] -prime = [] -for i in range(2, y + 1): -    for j in range(i * 2, y + 1, i): -        is_prime[j] = False -for i in range(y + 1): -    if is_prime[i]: -        prime.append(i) -for i in range(len(prime)): -    if prime[i] >= x: -        print((prime[i])) +while True: +    x_sqrt = int(x**0.5) +    for i in range(2, x_sqrt + 1): +        if x % i == 0: +            break +    else: +        print(x) -    else: -        continue +    x += 1