# Возвращаем первое простое число
# большее числа num
def simple_num(number):
count = 0
for i in range(2, number + 1):
if number % i == 0:
count += 1
if count == 1:
return True
else:
return False
#
def next_simple(num):
count_list = list(range(num + 1, num * 2 + 1))
for i in range(len(count_list)):
if simple_num(count_list[i]) == True:
return count_list[i]
break
print(next_simple(int(input())))