
import           Control.Applicative
import           Control.Monad
import           Data.List           hiding (union)
import           Text.Printf

main :: IO ()
main = mapM_ (print . process . read) . lines =<< getContents
  where
    process n = length $ takeWhile (<=n) (primesLimGEU 999999)

primesLimGEU :: Int -> [Int]
primesLimGEU m = 2 : sieve [3,5..m] where                         -- (* Euler's Sieve /lim /guard   *)
  sieve (p:xs)
   | p*p > m   = p : xs                                -- ... prevent INT wraparound too
   | True      = p : sieve (minus xs [p*x | x <- p:xs])
  sieve []     = []

minus :: [Int] -> [Int] -> [Int]
minus xs@(x:xt) ys@(y:yt) = case compare x y of
    LT -> x : minus xt ys
    EQ ->     minus xt yt
    GT ->     minus xs yt
minus a         b         = a
