import math

x = int(eval(input()))



n = 10**6

flag = [True]*(n+1)



for i in range(4, n+1, 2):

  flag[i] = False

  

t = int(n**0.5)+1

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

  for j in range(i+i, n+1, i):

    flag[j] = False



for i in range(x,n+1):

  if flag[i]:

    print(i)

    exit()
x = int(eval(input()))



n = 10**6

nums = [True]*(n+1)

nums[0] = nums[1] = False

for i in range(4, n+1, 2): nums[i] = False

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

  if nums[i]:

    for j in range(i+i, n, i):

      nums[j] = False



while True:

  if nums[x]:

    print(x)

    break

  x += 1
import math

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

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

-import math - -flag = [True] * (n + 1) +nums = [True] * (n + 1) +nums[0] = nums[1] = False -    flag[i] = False -t = int(n**0.5) + 1 -for i in range(3, t, 2): -    for j in range(i + i, n + 1, i): -        flag[j] = False -for i in range(x, n + 1): -    if flag[i]: -        print(i) -        exit() +    nums[i] = False +for i in range(3, int(n**0.5) + 1, 2): +    if nums[i]: +        for j in range(i + i, n, i): +            nums[j] = False +while True: +    if nums[x]: +        print(x) +        break +    x += 1