'use strict'


const check = (n) => {
  if (n < 2) return false
  let sqrt = Math.floor(Math.sqrt(n))
  for(var i = 2; i <= sqrt; ++i) {
    if(n % i === 0) return false
  }
  return true
}  

function Main(input) {
  input = parseInt(input.trim())

  while(true) {
    if(check(input)) {
      console.log(input)
      return
    }
    input += 1
  }

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