def prime_list(num)
  count = 0
  num_list = (2..num).to_a
  arr = []

  until num_list.empty?
    arr << num_list[0]

    num_list = num_list.select do |i|
      i % num_list[0] != 0
    end

    count += 1
  end

  arr
end

num_list = []

loop do
  n = gets.to_i
  break if n.zero?

  num_list << n
end

max = num_list.max
prime_list_of_max = prime_list(max)

num_list.each do |num|
  prime_count = prime_list_of_max.select { |i|
    i <= num
  }.length

  puts prime_count
end