q = []
loop do
  i = gets&.to_i
  break if i.nil? || i == 0
  q << i
end
max = q.max
arr = Array.new(max + 1)

(2..max).each do |i|
  next if !arr[i].nil? && !arr[i]
  arr[i] = true
  (2..(max / i).to_i).each do |j|
    idx = i * j
    break if idx > max
    arr[i * j] = false
  end
end

q.each do |que|
  p arr[1..que].select{|i| i}.size
end

