# ABC149 C - Next Prime

X = int(eval(input()))



def isPrime(n):

    cnt = 0

    for i in range(1, n + 1):

        if n % i == 0:

            cnt += 1

    if cnt == 2:

        return True

    else:

        return False



while True:

    if isPrime(X):

        print(X)

        break

    else:

        X += 1
# ABC149 C - Next Prime

X = int(eval(input()))



def isPrime(n):

    for i in range(2, n):

        if n % i == 0:

            return False

    return True



while True:

    if isPrime(X):

        print(X)

        break

    else:

        X += 1
# ABC149 C - Next Prime
X = int(eval(input()))


def isPrime(n):
    cnt = 0
    for i in range(1, n + 1):
        if n % i == 0:
            cnt += 1
    if cnt == 2:
        return True
    else:
        return False


while True:
    if isPrime(X):
        print(X)
        break
    else:
        X += 1

# ABC149 C - Next Prime
X = int(eval(input()))


def isPrime(n):
    for i in range(2, n):
        if n % i == 0:
            return False
    return True


while True:
    if isPrime(X):
        print(X)
        break
    else:
        X += 1

-    cnt = 0 -    for i in range(1, n + 1): +    for i in range(2, n): -            cnt += 1 -    if cnt == 2: -        return True -    else: -        return False +            return False +    return True