X = gets.to_i

found = false
candidate = X
while found == false do
  prime = true
  for i in 2..candidate do
    if candidate % i == 0 and candidate != i then
      prime = false
      break
    end
  end
  if prime then
    print candidate
    found = true
  else
    candidate += 1
  end
end