Approach hintTry it first, then revealHide
Use the sieve of Eratosthenes on [0, n): for each prime p, cross out multiples starting from p * p. Note that the count covers numbers strictly less than n.
Use the sieve of Eratosthenes on [0, n): for each prime p, cross out multiples starting from p * p. Note that the count covers numbers strictly less than n.