main = do
 let primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
      where isPrime n = null [i|i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]
 getContents >>= mapM_ (putStrLn . show . prime_number primes . read) . lines
  where prime_number ps n = length (takeWhile (<= n) ps)