Approach hintTry it first, then revealHide
With n at most 3000, sieve the primes and, for each prime, increment a counter at every multiple; then count the numbers whose counter is exactly 2.
With n at most 3000, sieve the primes and, for each prime, increment a counter at every multiple; then count the numbers whose counter is exactly 2.