{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Main (main) where
import Data.Function
import Control.Monad
import System.IO
import Data.Vector.Unboxed.Mutable as MV
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  fix $ \loop -> do
     eof <- isEOF
     unless eof $ do
        n <- readLn
        let result = count $ isPrimes n
        print result
        loop
  return ()

count :: V.Vector Bool -> Int
count = V.foldl' (+) 0 . V.map toInt
  where
    toInt x = if x
                 then 1
                 else 0

isPrimes :: Int -> V.Vector Bool
isPrimes size = V.create $ do
   v <- MV.replicate size True
   MV.write v 0 False
   MV.write v 1 False
   flip fix 1 $ \loop i -> do
     when (i*i < size) $ do
       prime <- MV.read v i
       when prime $ do
         sweep i v
       loop (i+1)
   return v
   where
     sweep n v = forM_ [n*2,n*3 .. MV.length v - 1] $ \i -> do
                       MV.write v i False