# -*- coding: utf-8 -*-



################ DANGER ################

test = ""

test = \

"""



"""

########################################

test = list(reversed(test.strip().splitlines()))

if test:

    def input2():

        return test.pop()

else:

    def input2():

        return input()

########################################  

        

n = int(input2())



def primes(n):

    ps = [2]

    for odd in range(3, n + 1, 2):

        for p in ps:

            if odd % p == 0:

                break

            if p ** 2 > odd:

                ps.append(odd)

                break

    return ps





def isprime(n):

    last = int(n**.5)

    for m in primes(last):

        if n % m == 0:

            return False

    return True





def nextprime(n):

    if n in primes(n):

        return n

    elif n == 1:

        return 2

    else:

        i = n

        while not isprime(i):

            i += 1

        return i





print(nextprime(n))

# -*- coding: utf-8 -*-

# Next Prime



import sys





TEST_INPUT = \

"""



100000



"""



TEST_OUTPUT = \

"""



100003



"""





def primes(n):

    if n == 0 or n == 1: return []

    

    ps = [2]

    for odd in range(3, n + 1, 2):

        for p in ps:

            if odd % p == 0:

                break

            if p ** 2 > odd:

                ps.append(odd)

                break

    return ps





def isprime(n):

    if n == 0 or n == 1: return False

    

    last = int(n**.5)

    for m in primes(last):

        if n % m == 0:

            return False

    return True





def nextprime(n):

    if n in primes(n):

        return n

    else:

        i = n

        while not isprime(i):

            i += 1

        return i





def main(stdin):

    n = int(stdin)

    print(nextprime(n))





if __name__ == "__main__":

    main(sys.stdin.read().strip())

# -*- coding: utf-8 -*-
################ DANGER ################
test = ""
test = """
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:

    def input2():
        return test.pop()

else:

    def input2():
        return input()


########################################
n = int(input2())


def primes(n):
    ps = [2]
    for odd in range(3, n + 1, 2):
        for p in ps:
            if odd % p == 0:
                break
            if p**2 > odd:
                ps.append(odd)
                break
    return ps


def isprime(n):
    last = int(n**0.5)
    for m in primes(last):
        if n % m == 0:
            return False
    return True


def nextprime(n):
    if n in primes(n):
        return n
    elif n == 1:
        return 2
    else:
        i = n
        while not isprime(i):
            i += 1
        return i


print(nextprime(n))

# -*- coding: utf-8 -*-
# Next Prime
import sys

TEST_INPUT = """
100000
"""
TEST_OUTPUT = """
100003
"""


def primes(n):
    if n == 0 or n == 1:
        return []
    ps = [2]
    for odd in range(3, n + 1, 2):
        for p in ps:
            if odd % p == 0:
                break
            if p**2 > odd:
                ps.append(odd)
                break
    return ps


def isprime(n):
    if n == 0 or n == 1:
        return False
    last = int(n**0.5)
    for m in primes(last):
        if n % m == 0:
            return False
    return True


def nextprime(n):
    if n in primes(n):
        return n
    else:
        i = n
        while not isprime(i):
            i += 1
        return i


def main(stdin):
    n = int(stdin)
    print(nextprime(n))


if __name__ == "__main__":
    main(sys.stdin.read().strip())

-################ DANGER ################ -test = "" -test = """ +# Next Prime +import sys + +TEST_INPUT = """ +100000 -######################################## -test = list(reversed(test.strip().splitlines())) -if test: - -    def input2(): -        return test.pop() - -else: - -    def input2(): -        return input() - - -######################################## -n = int(input2()) +TEST_OUTPUT = """ +100003 +""" +    if n == 0 or n == 1: +        return [] +    if n == 0 or n == 1: +        return False -    elif n == 1: -        return 2 -print(nextprime(n)) +def main(stdin): +    n = int(stdin) +    print(nextprime(n)) + + +if __name__ == "__main__": +    main(sys.stdin.read().strip())