#Bash + coreutils, 30

<!-- language-all: lang-bash -->

    seq $1|factor|egrep -c :.\\S+$

[Ideone.][1]

---
#Bash + coreutils + BSD-games package, 22

    primes 1 $[$1+1]|wc -l

This shorter answer requires that you have the bsdgames package installed: `sudo apt install bsdgames`.

  [1]: https://ideone.com/VwKgoN