max = 999999
prime_list = [false, false] + [true] * (max - 1)

loop_max = (max**0.5)

(2..loop_max).each do |i|
  next unless prime_list[i]
  limit = ((max.to_f/i.to_f) - i.to_f).truncate
  base = (i*i)
  (0..limit).each do |j|
    prime_list[base + i*j] = false
  end
end

while gets do
  count = 0
  2.upto($_.to_i) { |i| count += 1 if prime_list[i] }
  puts count
end