"use strict";
const fs = require("fs");

const X = parseInt(fs.readFileSync("/dev/stdin", { encoding: "utf8" }));

function isPrime(n) {
  const m = Math.ceil(Math.sqrt(n));
  for (let i = 2; i < m; ++i) {
    if (n % i === 0) {
      return false;
    }
  }
  return true;
}

function main() {
  let i = X;
  while (true) {
    if (isPrime(i)) {
      return i;
    }
    i++;
  }
}

console.log(main());
