x=int(eval(input()))

flag=0

while(1):

    flag=0

    for i in range(2,int(x/2+1)):

        if x%i==0:

            flag=1

            x+=1

            break

    if flag==0:

        print(x)

        break

n=int(eval(input()))

flag=1

for i in range(n,10*n):

  j=2

  flag=1

  while(j<=int(i**(0.5))):

    if(i%j==0):

      flag=0

      break

    j+=1

  if(flag==1):      

    print(i)

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

n = int(eval(input()))
flag = 1
for i in range(n, 10 * n):
    j = 2
    flag = 1
    while j <= int(i ** (0.5)):
        if i % j == 0:
            flag = 0
            break
        j += 1
    if flag == 1:
        print(i)
        break

-x = int(eval(input())) -flag = 0 -while 1: -    flag = 0 -    for i in range(2, int(x / 2 + 1)): -        if x % i == 0: -            flag = 1 -            x += 1 +n = int(eval(input())) +flag = 1 +for i in range(n, 10 * n): +    j = 2 +    flag = 1 +    while j <= int(i ** (0.5)): +        if i % j == 0: +            flag = 0 -    if flag == 0: -        print(x) +        j += 1 +    if flag == 1: +        print(i)