require 'prime'

$primes = []

def main
  $primes = Prime.first 80000
  while num = gets
    num = num.chomp.to_i
    puts solve(num).to_s
  end
end

def solve num
  nn = $primes.bsearch { |x| x >= num}
  $primes.index nn
end

main