main = do
 let primes = id $! takeWhile (<=999999) (sieve [2..])
      where sieve (p:xs) = p : sieve [x | x<-xs, (mod x p) /= 0]
 getContents >>= mapM_ (putStrLn . show . prime_number primes . read) . lines
  where prime_number ps n = length (takeWhile (<= n) ps)