main = do
  s <- getContents
  putStr . unlines . map (show . length . primesUnder . read) . lines $ s

primesUnder n = takeWhile (<= n) primes


-- The following efficient Eratosthenes' sieve is borrowed from:
-- http://en.literateprograms.org/Sieve_of_Eratosthenes_(Haskell) and
-- https://wiki.haskell.org/Prime_numbers

primes = [2, 3, 5] ++ ([7, 9 ..] `minus` nonprimes)
nonprimes = foldr1 union' [[p*p, p*p + 2*p ..] | p <- tail primes]
  where
    union' (x:xs) ys = x : union xs ys

-- union and subtraction of two infinite sorted sets
union (x:xs) (y:ys) =
  case compare x y of
    LT -> x : union xs (y:ys)
    EQ -> x : union xs ys
    GT -> y : union (x:xs) ys
minus (x:xs) (y:ys) =
  case compare x y of
    LT -> x : minus xs (y:ys)
    EQ -> minus xs ys
    GT -> minus (x:xs) ys