require 'prime' N = gets.to_i primes = Prime.each(1_000_000).to_a.select { |x| x > 10 ** 5 }.take(N - 1) if N == 1 puts 1 else puts primes.last end