x = int(eval(input()))



for i in range(x,10**5+100):

    flg = 'so'

    for j in range(2,x):

        

        if i % j == 0:

            flg = 'no'

   

    if flg == 'so':

        print(i)

        exit()
x = int(eval(input()))



for i in range(x,10**5+100):

    flg = 'so'

    for j in range(2,x):

        

        if i % j == 0:

            flg = 'no'

            break

   

    if flg == 'so':

        print(i)

        exit()
x = int(eval(input()))
for i in range(x, 10**5 + 100):
    flg = "so"
    for j in range(2, x):
        if i % j == 0:
            flg = "no"
    if flg == "so":
        print(i)
        exit()

x = int(eval(input()))
for i in range(x, 10**5 + 100):
    flg = "so"
    for j in range(2, x):
        if i % j == 0:
            flg = "no"
            break
    if flg == "so":
        print(i)
        exit()

+            break