#!/usr/bin/env ruby -n
BEGIN{
  is_prime = [false, false] + Array.new(999999, true)
  is_prime.each.with_index do |p, i|
    next unless p
    ((i*i)...is_prime.size).step(i).each do |j|
      is_prime[j] = false
    end
  end
}
p is_prime.take($_.to_i+1).select{|a|a}.size