X=int(eval(input()))

flag = True

if X == 2:

    print(X)

else:

    while flag:

        i = 2

        while i<X:

            if X%i == 0:

                break

            if i == X-1:

                print(X)

                flag = False

                break

            i = i+1

        X = X+1
X=int(eval(input()))

def is_prime(q,k=100):

    q = abs(q)

    if q == 2: return True

    if q < 2 or q&1 == 0: return False

    for i in range(3,k):

        x,y = q,i

        while y:

            x, y =  y, x % y

        if x != 1: continue

        if pow(i, q-1, q) != 1:

            return False

    return True

flag=False

while(flag==False):

    if is_prime(X):

        print(X)

        flag=True

        break

    X+=1
X = int(eval(input()))
flag = True
if X == 2:
    print(X)
else:
    while flag:
        i = 2
        while i < X:
            if X % i == 0:
                break
            if i == X - 1:
                print(X)
                flag = False
                break
            i = i + 1
        X = X + 1

X = int(eval(input()))


def is_prime(q, k=100):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    for i in range(3, k):
        x, y = q, i
        while y:
            x, y = y, x % y
        if x != 1:
            continue
        if pow(i, q - 1, q) != 1:
            return False
    return True


flag = False
while flag == False:
    if is_prime(X):
        print(X)
        flag = True
        break
    X += 1

-flag = True -if X == 2: -    print(X) -else: -    while flag: -        i = 2 -        while i < X: -            if X % i == 0: -                break -            if i == X - 1: -                print(X) -                flag = False -                break -            i = i + 1 -        X = X + 1 + + +def is_prime(q, k=100): +    q = abs(q) +    if q == 2: +        return True +    if q < 2 or q & 1 == 0: +        return False +    for i in range(3, k): +        x, y = q, i +        while y: +            x, y = y, x % y +        if x != 1: +            continue +        if pow(i, q - 1, q) != 1: +            return False +    return True + + +flag = False +while flag == False: +    if is_prime(X): +        print(X) +        flag = True +        break +    X += 1