N = int(eval(input()))



ans = -1

x = N

while(ans == -1):

    if all([x % i != 0 for i in range(2, x)]):

        ans = x

    else:

        x += 1

print(ans)
x=int(eval(input()))

f=0

if x == 2:

	print((2))

else:

	for i in range(x,10**6):

		for j in range(2,i//2+2):

			if i%j == 0:

				break

		else:

			f=i

			break

	print(f)

N = int(eval(input()))
ans = -1
x = N
while ans == -1:
    if all([x % i != 0 for i in range(2, x)]):
        ans = x
    else:
        x += 1
print(ans)

x = int(eval(input()))
f = 0
if x == 2:
    print((2))
else:
    for i in range(x, 10**6):
        for j in range(2, i // 2 + 2):
            if i % j == 0:
                break
        else:
            f = i
            break
    print(f)

-N = int(eval(input())) -ans = -1 -x = N -while ans == -1: -    if all([x % i != 0 for i in range(2, x)]): -        ans = x -    else: -        x += 1 -print(ans) +x = int(eval(input())) +f = 0 +if x == 2: +    print((2)) +else: +    for i in range(x, 10**6): +        for j in range(2, i // 2 + 2): +            if i % j == 0: +                break +        else: +            f = i +            break +    print(f)