x = int(eval(input()))

p = [True] * 100004

p[0] = False

p[1] = False

for i in range(int(100003 ** 0.5)):

    if p[i] == False:

        continue

    for j in range(2, 100003 // i + 1):

        p[i * j] = False

for i in range(x, 100004):

    if p[i] == True:

        print(i)

        break
x = int(eval(input()))

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

    for j in range(2, i):

        if i % j == 0:

            break

    else:

        print(i)

        break
x = int(eval(input()))
p = [True] * 100004
p[0] = False
p[1] = False
for i in range(int(100003**0.5)):
    if p[i] == False:
        continue
    for j in range(2, 100003 // i + 1):
        p[i * j] = False
for i in range(x, 100004):
    if p[i] == True:
        print(i)
        break

x = int(eval(input()))
for i in range(x, 100003 + 1):
    for j in range(2, i):
        if i % j == 0:
            break
    else:
        print(i)
        break

-p = [True] * 100004 -p[0] = False -p[1] = False -for i in range(int(100003**0.5)): -    if p[i] == False: -        continue -    for j in range(2, 100003 // i + 1): -        p[i * j] = False -for i in range(x, 100004): -    if p[i] == True: +for i in range(x, 100003 + 1): +    for j in range(2, i): +        if i % j == 0: +            break +    else: