x=int(eval(input()))

while True:

  cnt=0

  for i in range(2,x//2):

    if x%i==0:

      cnt+=1

      break

  if cnt==0:

    print(x)

    break

  else:

    x+=1

    continue
x=int(eval(input()))

while True:

  cnt=0

  for i in range(2,x//2):

    if x%i==0:

      cnt+=1

      break

  if cnt==0:

    print(x)

    break

  elif cnt==1:

    x+=1

    continue

x = int(eval(input()))
while True:
    cnt = 0
    for i in range(2, x // 2):
        if x % i == 0:
            cnt += 1
            break
    if cnt == 0:
        print(x)
        break
    else:
        x += 1
        continue

x = int(eval(input()))
while True:
    cnt = 0
    for i in range(2, x // 2):
        if x % i == 0:
            cnt += 1
            break
    if cnt == 0:
        print(x)
        break
    elif cnt == 1:
        x += 1
        continue

-    else: +    elif cnt == 1: