import Control.Applicative ((<$>)) import Data.List import qualified Data.ByteString.Char8 as B8 main :: IO () main = do l <- getl read getLine solve l <$> getInts >>= print solve :: Int -> [Int] -> Int solve l = subtract 1 . length . takeWhile (<= l) . scanl (+) 0 . sort getInts :: IO [Int] getInts = map f . B8.words <$> B8.getLine where f x = let Just (n, _) = B8.readInt x in n getl :: (String -> a) -> IO a getl f = f <$> getLine