/**
 * @param input number
 */
function Main(input) {
  if (num === 2) {
    console.log(2);
    return;
  }

  for (var num = input + (input + 1) % 2; true; num += 2) {
    if (isPrime(num)) {
      break;
    }
  }

  console.log(num);
}

function isPrime(num) {
  for (var i = 3; i < num; i++) {
    if (num % i) {
      return false;
    }
  }
  return true;
}

Main(+require("fs").readFileSync("/dev/stdin", "utf8").trim());