while gets do
  max = $_.to_i

  prime_list = [0, 0] + [1] * (max - 1)

  (2..max).each do |i|
    next if prime_list[i] != 1
    (0..max).each do |j|
      break if (i*i) + i*j > max
      prime_list[(i*i) + i*j] = 0
    end
  end
  puts prime_list.inject(:+)
end