X = int(eval(input()))



def is_prime(x):

	if x == 2:

		return True

	if x % 2 == 0:

		return False

	else:

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

			if x % i == 0:

				return False

		return True



a = X

if (X % 2 == 0) & (X > 2):

	a += 1

while 1:	

	if is_prime(a):

		print(a)

		break

	else:

		a += 2

			
import math

X = int(eval(input()))



def is_prime(x):

	if x == 2:

		return True

	if x % 2 == 0:

		return False

	else:

		for i in range(3, int(math.sqrt(x))+1, 2):

			if x % i == 0:

				return False

		return True



a = X

if (X % 2 == 0) & (X > 2):

	a += 1

while 1:	

	if is_prime(a):

		print(a)

		break

	else:

		a += 2

			
X = int(eval(input()))


def is_prime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    else:
        for i in range(3, x, 2):
            if x % i == 0:
                return False
        return True


a = X
if (X % 2 == 0) & (X > 2):
    a += 1
while 1:
    if is_prime(a):
        print(a)
        break
    else:
        a += 2

import math

X = int(eval(input()))


def is_prime(x):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    else:
        for i in range(3, int(math.sqrt(x)) + 1, 2):
            if x % i == 0:
                return False
        return True


a = X
if (X % 2 == 0) & (X > 2):
    a += 1
while 1:
    if is_prime(a):
        print(a)
        break
    else:
        a += 2

+import math + -        for i in range(3, x, 2): +        for i in range(3, int(math.sqrt(x)) + 1, 2):