x=int(eval(input()))

cont=0

for i in range(x,10**12):

    for j in range(2,i):

        if i%j==0:

            cont+=1

    if cont==0:

        print(i)

        exit()

    cont=0  
x=int(eval(input()))

j=x

while True:

    cnt=0

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

        if j%i==0:

            cnt+=1

    if cnt==1:

        print(j)

        exit()

    else:

        j+=1
x = int(eval(input()))
cont = 0
for i in range(x, 10**12):
    for j in range(2, i):
        if i % j == 0:
            cont += 1
    if cont == 0:
        print(i)
        exit()
    cont = 0

x = int(eval(input()))
j = x
while True:
    cnt = 0
    for i in range(2, j + 1):
        if j % i == 0:
            cnt += 1
    if cnt == 1:
        print(j)
        exit()
    else:
        j += 1

-cont = 0 -for i in range(x, 10**12): -    for j in range(2, i): -        if i % j == 0: -            cont += 1 -    if cont == 0: -        print(i) +j = x +while True: +    cnt = 0 +    for i in range(2, j + 1): +        if j % i == 0: +            cnt += 1 +    if cnt == 1: +        print(j) -    cont = 0 +    else: +        j += 1