import Control.Applicative ((<$>)) import Control.Monad (when, forM_, foldM) import Data.Vector.Unboxed.Mutable (IOVector, STVector) import qualified Data.Vector.Unboxed.Mutable as VM main :: IO () main = solve >>= print solve :: IO Int solve = do [n, k] <- map read <$> words <$> getLine :: IO [Int] pt <- VM.replicate (n+1) 0 :: IO (IOVector Int) forM_ [2 .. n] $ \i -> do x <- VM.read pt i when (x == 0) $ do VM.write pt i 1 forM_ [2*i, 3*i .. n] $ \j -> do modify pt j (+1) foldM (f k pt) 0 [2 .. n] where f k pt c i = do x <- VM.read pt i if x >= k then return (c+1) else return c modify :: IOVector Int -> Int -> (Int -> Int) -> IO () modify v i f = do x <- VM.read v i VM.write v i (f x)