# import numpy as np

import math

import sys

input = sys.stdin.readline



X = int(eval(input()))



if X == 2:

    print(X)

    sys.exit()



def segment_sieve(a,b):

    ass = []

    is_prime_small = [True] * (int(b**0.5)+1)

    is_prime = [True] * (b-a)

    for i in range(2,int(b**0.5)):

        if is_prime_small[i]:

            j = 2*i

            while j**2 < b:

                is_prime_small[j] = False

                j += i

            j = max(2*i,((a+i-1)//i)*i)

            while j < b:

                is_prime[j-a] = False

                j += i

    for i in range(len(is_prime)):

        if is_prime[i]:

            ass.append(a+i)

    if ass[0] == 1:

        del ass[0]

    return ass



list = segment_sieve(X,100004)

res = list[0]



print(res)

# import numpy as np

import math

import sys

input = sys.stdin.readline



X = int(eval(input()))



def is_prime(x):

    if x <= 1:

        return False

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

        if x % i == 0:

            return False

    return True



while not is_prime(X):

    X += 1



print(X)

# import numpy as np
import math
import sys

input = sys.stdin.readline
X = int(eval(input()))
if X == 2:
    print(X)
    sys.exit()


def segment_sieve(a, b):
    ass = []
    is_prime_small = [True] * (int(b**0.5) + 1)
    is_prime = [True] * (b - a)
    for i in range(2, int(b**0.5)):
        if is_prime_small[i]:
            j = 2 * i
            while j**2 < b:
                is_prime_small[j] = False
                j += i
            j = max(2 * i, ((a + i - 1) // i) * i)
            while j < b:
                is_prime[j - a] = False
                j += i
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(a + i)
    if ass[0] == 1:
        del ass[0]
    return ass


list = segment_sieve(X, 100004)
res = list[0]
print(res)

# import numpy as np
import math
import sys

input = sys.stdin.readline
X = int(eval(input()))


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


while not is_prime(X):
    X += 1
print(X)

-if X == 2: -    print(X) -    sys.exit() -def segment_sieve(a, b): -    ass = [] -    is_prime_small = [True] * (int(b**0.5) + 1) -    is_prime = [True] * (b - a) -    for i in range(2, int(b**0.5)): -        if is_prime_small[i]: -            j = 2 * i -            while j**2 < b: -                is_prime_small[j] = False -                j += i -            j = max(2 * i, ((a + i - 1) // i) * i) -            while j < b: -                is_prime[j - a] = False -                j += i -    for i in range(len(is_prime)): -        if is_prime[i]: -            ass.append(a + i) -    if ass[0] == 1: -        del ass[0] -    return ass +def is_prime(x): +    if x <= 1: +        return False +    for i in range(2, int(math.sqrt(x)) + 1): +        if x % i == 0: +            return False +    return True -list = segment_sieve(X, 100004) -res = list[0] -print(res) +while not is_prime(X): +    X += 1 +print(X)