x = int(eval(input()))

ok = False



while ok == False:

    ok = True

    for i in range(2, x):

        if x%i == 0:

            ok = False

            x += 1

            #print("####")

            break

    if ok == True:

        print(x)

        break

x = int(eval(input()))

ok = False



while ok == False:

    ok = True

    for i in range(2, int(x/2)):

        if x%i == 0:

            ok = False

            x += 1

            #print("####")

            break

    if ok == True:

        print(x)

        break

x = int(eval(input()))
ok = False
while ok == False:
    ok = True
    for i in range(2, x):
        if x % i == 0:
            ok = False
            x += 1
            # print("####")
            break
    if ok == True:
        print(x)
        break

x = int(eval(input()))
ok = False
while ok == False:
    ok = True
    for i in range(2, int(x / 2)):
        if x % i == 0:
            ok = False
            x += 1
            # print("####")
            break
    if ok == True:
        print(x)
        break

-    for i in range(2, x): +    for i in range(2, int(x / 2)):