x = int(eval(input()))



flag = [True]*(10**6+1)

flag[0] = flag[1] = False



for i in range(4, 10**6+1,2): flag[i] = False

for i in range(3, int((10**6)**0.5)+1, 2):

  if flag[i]:

    for j in range(i+i, 10**6+1, i): flag[j] = False

      

while True:

  if flag[x]:

    print(x)

    exit()

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



nums = [True]*(10**6)

n = int(10**6**0.5)

for i in range(4, 10**6, 2): nums[i] = False

for i in range(3, n, 2):

  if nums[i]:

    for j in range(i+i, 10**6, i): nums[j] = False

      

while True:

  if nums[x]:

    print(x)

    break

  x += 1
x = int(eval(input()))
flag = [True] * (10**6 + 1)
flag[0] = flag[1] = False
for i in range(4, 10**6 + 1, 2):
    flag[i] = False
for i in range(3, int((10**6) ** 0.5) + 1, 2):
    if flag[i]:
        for j in range(i + i, 10**6 + 1, i):
            flag[j] = False
while True:
    if flag[x]:
        print(x)
        exit()
    x += 1

x = int(eval(input()))
nums = [True] * (10**6)
n = int(10**6**0.5)
for i in range(4, 10**6, 2):
    nums[i] = False
for i in range(3, n, 2):
    if nums[i]:
        for j in range(i + i, 10**6, i):
            nums[j] = False
while True:
    if nums[x]:
        print(x)
        break
    x += 1

-flag = [True] * (10**6 + 1) -flag[0] = flag[1] = False -for i in range(4, 10**6 + 1, 2): -    flag[i] = False -for i in range(3, int((10**6) ** 0.5) + 1, 2): -    if flag[i]: -        for j in range(i + i, 10**6 + 1, i): -            flag[j] = False +nums = [True] * (10**6) +n = int(10**6**0.5) +for i in range(4, 10**6, 2): +    nums[i] = False +for i in range(3, n, 2): +    if nums[i]: +        for j in range(i + i, 10**6, i): +            nums[j] = False -    if flag[x]: +    if nums[x]: -        exit() +        break