X=int(eval(input()))

while True:

    for x in range(2,X):

        if X%x==0:

            break

    else:

        print(X)

        break

    X+=1
X=int(eval(input()))

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

    for i in range(2,int(x**.5)+1):

        if x%i==0:

            break

    else:

        print(x)

        break
X = int(eval(input()))
while True:
    for x in range(2, X):
        if X % x == 0:
            break
    else:
        print(X)
        break
    X += 1

X = int(eval(input()))
for x in range(X, 2 * X):
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            break
    else:
        print(x)
        break

-while True: -    for x in range(2, X): -        if X % x == 0: +for x in range(X, 2 * X): +    for i in range(2, int(x**0.5) + 1): +        if x % i == 0: -        print(X) +        print(x) -    X += 1