nn=int(eval(input()))

n=10**5+100

ar=[0]*(n)

ar[1]=0

ans=0

pre=1

for i in range(2,n):

    if ar[i]==0:



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

            ar[j]=1

ans=1

if ar[nn]==0:

    print(nn)

else:

        

    for i in range(nn,n):

        if ar[i]==0:

            print(i)

            break

        



        
nn=int(eval(input()))

n=10**5+100

ar=[0]*(n)

ar[1]=0

ans=0

pre=1

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

    if ar[i]==0:



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

            ar[j]=1

ans=1

if ar[nn]==0:

    print(nn)

else:

        

    for i in range(nn,n):

        if ar[i]==0:

            print(i)

            break

        



        
nn = int(eval(input()))
n = 10**5 + 100
ar = [0] * (n)
ar[1] = 0
ans = 0
pre = 1
for i in range(2, n):
    if ar[i] == 0:
        for j in range(2 * i, n, i):
            ar[j] = 1
ans = 1
if ar[nn] == 0:
    print(nn)
else:
    for i in range(nn, n):
        if ar[i] == 0:
            print(i)
            break

nn = int(eval(input()))
n = 10**5 + 100
ar = [0] * (n)
ar[1] = 0
ans = 0
pre = 1
for i in range(2, int((n**0.5)) + 1):
    if ar[i] == 0:
        for j in range(2 * i, n, i):
            ar[j] = 1
ans = 1
if ar[nn] == 0:
    print(nn)
else:
    for i in range(nn, n):
        if ar[i] == 0:
            print(i)
            break

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