import qualified Data.ByteString.Char8 as BC
import Data.STRef
import Control.Monad
import Control.Monad.ST
import Data.Maybe(fromJust)
 
main :: IO()
main = BC.getContents >>= mapM_ (print . solve . fst . fromJust . BC.readInt) . BC.lines

solve :: Int -> Int
solve n = runST $ do
    a <- newSTRef 0
    forM_ [2..n] $ \z -> do
        a' <- readSTRef a
        when (isPrime z) $ modifySTRef a (+ 1)
    readSTRef a

isPrime :: Int -> Bool
isPrime 2 = True
isPrime n
    | n < 2           = False
    | n `mod` 2 == 0  = False
    | otherwise       = testDiv 3 n
    where testDiv :: Int -> Int -> Bool
          testDiv i n
              | i * i > n      = True
              | n `mod` i == 0 = False
              | otherwise      = testDiv (i + 2) n
