from sys import stdin



input=stdin.readline



def isPrime(x):

  for div in range(2, x // 2 + 1):

    if x % div == 0:

      return False



  return True



X = int(eval(input()))



if isPrime(X):

   print(X)

   exit()



while (X < 10 ** 5):

  X+=1

  if isPrime(X):

    print(X)

    exit()



#100000より大きい素数のうち最小のもの

print((100003))
from sys import stdin

import math



input=stdin.readline



def isPrime(x):

  if x % 2 == 0:

    return False

  for div in range(3, math.floor(x **(0.5)) + 1,2):

    if x % div == 0:

      return False



  return True



X = int(eval(input()))

if X == 2:

  print((2))

  exit()



if X % 2 == 0:

  X+=1



if isPrime(X):

   print(X)

   exit()



while (True):

  X += 2

  if isPrime(X):

    print(X)

    exit()

from sys import stdin

input = stdin.readline


def isPrime(x):
    for div in range(2, x // 2 + 1):
        if x % div == 0:
            return False
    return True


X = int(eval(input()))
if isPrime(X):
    print(X)
    exit()
while X < 10**5:
    X += 1
    if isPrime(X):
        print(X)
        exit()
# 100000より大きい素数のうち最小のもの
print((100003))

from sys import stdin
import math

input = stdin.readline


def isPrime(x):
    if x % 2 == 0:
        return False
    for div in range(3, math.floor(x ** (0.5)) + 1, 2):
        if x % div == 0:
            return False
    return True


X = int(eval(input()))
if X == 2:
    print((2))
    exit()
if X % 2 == 0:
    X += 1
if isPrime(X):
    print(X)
    exit()
while True:
    X += 2
    if isPrime(X):
        print(X)
        exit()

+import math -    for div in range(2, x // 2 + 1): +    if x % 2 == 0: +        return False +    for div in range(3, math.floor(x ** (0.5)) + 1, 2): +if X == 2: +    print((2)) +    exit() +if X % 2 == 0: +    X += 1 -while X < 10**5: -    X += 1 +while True: +    X += 2 -# 100000より大きい素数のうち最小のもの -print((100003))