def prime(n)
  f = Array.new(n+1, 0)
  i = 2
  while i * i <= n do
    if f[i] == 0
      k = i * i
      while k <= n do
        if f[k] == 0
          f[k] = i
        end
        k += i
      end
    end
    i += 1
  end
  primes =[]
  f.each.with_index(0) do |i, index|
    if i == 0 && index >= 2
      primes << index
    end
  end
  primes.size
end

while (n = gets.to_i) != 0 do
  puts prime(n)
end
