X = int(eval(input()))



fact = [True] * (10 ** 5 + 1000)

fact[0],fact[1] = False,False

for i in range(2,len(fact)):

  if fact[i]:

    for j in range(i * 2, len(fact), i):

      fact[j] = False

      

for i in range(X,len(fact)):

  if fact[i]:

    print(i)

    break
X = int(eval(input()))



def checkfact(x):

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

    if x % i == 0:

      return False

  return True



while True:

  if checkfact(X):

    print(X)

    break

  X += 1
X = int(eval(input()))
fact = [True] * (10**5 + 1000)
fact[0], fact[1] = False, False
for i in range(2, len(fact)):
    if fact[i]:
        for j in range(i * 2, len(fact), i):
            fact[j] = False
for i in range(X, len(fact)):
    if fact[i]:
        print(i)
        break

X = int(eval(input()))


def checkfact(x):
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True


while True:
    if checkfact(X):
        print(X)
        break
    X += 1

-fact = [True] * (10**5 + 1000) -fact[0], fact[1] = False, False -for i in range(2, len(fact)): -    if fact[i]: -        for j in range(i * 2, len(fact), i): -            fact[j] = False -for i in range(X, len(fact)): -    if fact[i]: -        print(i) + + +def checkfact(x): +    for i in range(2, int(x**0.5) + 1): +        if x % i == 0: +            return False +    return True + + +while True: +    if checkfact(X): +        print(X) +    X += 1