x = int(eval(input()))

num = 0



for i in range(x,x*2):

    for j in range(2,x//2):

        if i%j == 0:

            num += 1

            continue

    if num == 0:

        print(i)

        exit(0)

    num = 0
import math

x = int(eval(input()))

for i in range(x, x * 2):

    flag = True

    for j in range(2, math.floor(math.sqrt(x))+1):

        if i % j == 0:

            flag = False

            break

    if flag:

        print(i)

        exit(0)
x = int(eval(input()))
num = 0
for i in range(x, x * 2):
    for j in range(2, x // 2):
        if i % j == 0:
            num += 1
            continue
    if num == 0:
        print(i)
        exit(0)
    num = 0

import math

x = int(eval(input()))
for i in range(x, x * 2):
    flag = True
    for j in range(2, math.floor(math.sqrt(x)) + 1):
        if i % j == 0:
            flag = False
            break
    if flag:
        print(i)
        exit(0)

+import math + -num = 0 -    for j in range(2, x // 2): +    flag = True +    for j in range(2, math.floor(math.sqrt(x)) + 1): -            num += 1 -            continue -    if num == 0: +            flag = False +            break +    if flag: -    num = 0