import sys

import math

input = sys.stdin.readline



def multiples(n):

    for i in range(3,100003):

        yield i*n

        if i*n > 100003:

            break



def sosuu(x):

    if x == 2 : return 2

    d = set()

    end = math.ceil(math.sqrt(x))

    d = d.union(multiples(2))

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

        if i not in d:

            d = d.union(set(multiples(i)))

    

    i = x if x % 2 != 0 else x+1

    while True:

        if i not in d:

            return i

        i += 2



def main():

    x = int(eval(input()))

    print((sosuu(x)))



if __name__ == "__main__":

    main()
import sys

import math

input = sys.stdin.readline



def is_prime(x):

    if x <= 1: 

        return False

    for i in range(2,math.ceil(x**0.5)):

        if x%i==0: 

            return False

    return True

def main():

    x = int(eval(input()))

    p = x

    while not is_prime(p):

        p += 1

    print(p)



if __name__ == "__main__":

    main()
import sys
import math

input = sys.stdin.readline


def multiples(n):
    for i in range(3, 100003):
        yield i * n
        if i * n > 100003:
            break


def sosuu(x):
    if x == 2:
        return 2
    d = set()
    end = math.ceil(math.sqrt(x))
    d = d.union(multiples(2))
    for i in range(3, end, 2):
        if i not in d:
            d = d.union(set(multiples(i)))
    i = x if x % 2 != 0 else x + 1
    while True:
        if i not in d:
            return i
        i += 2


def main():
    x = int(eval(input()))
    print((sosuu(x)))


if __name__ == "__main__":
    main()

import sys
import math

input = sys.stdin.readline


def is_prime(x):
    if x <= 1:
        return False
    for i in range(2, math.ceil(x**0.5)):
        if x % i == 0:
            return False
    return True


def main():
    x = int(eval(input()))
    p = x
    while not is_prime(p):
        p += 1
    print(p)


if __name__ == "__main__":
    main()

-def multiples(n): -    for i in range(3, 100003): -        yield i * n -        if i * n > 100003: -            break - - -def sosuu(x): -    if x == 2: -        return 2 -    d = set() -    end = math.ceil(math.sqrt(x)) -    d = d.union(multiples(2)) -    for i in range(3, end, 2): -        if i not in d: -            d = d.union(set(multiples(i))) -    i = x if x % 2 != 0 else x + 1 -    while True: -        if i not in d: -            return i -        i += 2 +def is_prime(x): +    if x <= 1: +        return False +    for i in range(2, math.ceil(x**0.5)): +        if x % i == 0: +            return False +    return True -    print((sosuu(x))) +    p = x +    while not is_prime(p): +        p += 1 +    print(p)