/**
 * @param input number
 */
function Main(input) {
  // 偶数のみで検証するため2は含まない
  const prevPrimes = [];

  if (num === 2) {
    console.log(2);
    return;
  }

  var num;
  const sqrt = Math.sqrt(input);
  for (num = 3; num <= sqrt; num += 2) {
    if (isPrime(num, prevPrimes)) {
      prevPrimes.push(num);
    }
  }
  for (; true; num += 2) {
    if (isPrime(num, prevPrimes)) {
      break;
    }
  }

  console.log(prevPrimes);

  console.log(num);
}

function isPrime(num, prevPrimes) {
  return prevPrimes.every((prime) => num % prime);
}

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