n = int(eval(input()))

while 1:

  for i in range(2, n):

    if n % i == 0:

      break

  else:

    print(n)

    break

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

while 1:

  if all(x%i for i in range(2,int(x**.5)+1)):

    print(x); break

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

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

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