N = 1000000

@primeArr = Array.new(N, 1)
@primeArr[0..1] = [0, 0]

def calcPrimeNum(n) 
  nsqrt = ("%d" % N**0.5).to_i
  (2..nsqrt).each do |checknum|
    (checknum*2).step(N-1, checknum) do |notprime|
      @primeArr[notprime] = 0
    end
  end
end

calcPrimeNum(N)

while n = gets do
  n = n.chomp.to_i
  p @primeArr[0..n].sum
end
