
n = 1_000_000

ns = Math.sqrt(n).to_i + 1

is_prime = [false, false] + [true]*(n-1)

2.upto(ns) do |i|
  next unless is_prime[i]
  (i*i).step(n, i) do |j|
    is_prime[j] = false
  end
end

count = 0
count_list = (0..n).map do |i|
  count += 1 if is_prime[i]
  count
end

while n = gets.to_i
  break if n <= 0
  puts count_list[n]
end