X = int(eval(input()))

LEN = int(1e6)

p = [True] * LEN



p[0] = False

p[1] = False



for i in range(LEN):

  if p[i]:

    for j in range(i * 2, LEN, i):

      p[j] = False



for i in range(X, LEN):

  if p[i]:

    print(i)

    exit()

X = int(eval(input()))

LEN = int(1e6)

p = [True] * LEN



p[0] = False

p[1] = False



for i in range(LEN):

  if p[i]:

    if i >= X:

      print(i)

      exit()

      

    for j in range(i * 2, LEN, i):

      p[j] = False



X = int(eval(input()))
LEN = int(1e6)
p = [True] * LEN
p[0] = False
p[1] = False
for i in range(LEN):
    if p[i]:
        for j in range(i * 2, LEN, i):
            p[j] = False
for i in range(X, LEN):
    if p[i]:
        print(i)
        exit()

X = int(eval(input()))
LEN = int(1e6)
p = [True] * LEN
p[0] = False
p[1] = False
for i in range(LEN):
    if p[i]:
        if i >= X:
            print(i)
            exit()
        for j in range(i * 2, LEN, i):
            p[j] = False

+        if i >= X: +            print(i) +            exit() -for i in range(X, LEN): -    if p[i]: -        print(i) -        exit()