import Control.Monad
import Data.List

data Katana = Throw 
            | Cut
            deriving (Show, Eq, Ord)

main = do
  [n, h] <- map read . words <$> getLine :: IO [Int]  

  print . solve 0 h . reverse . sort . concat =<< replicateM n (do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    return [(a, Cut), (b, Throw)])

solve :: Int -> Int -> [(Int, Katana)] -> Int
solve i h ((n, t): ns)
    | h <= 0     = i
    | t == Cut   = solve (i+1) (h-n) ((n, t):ns)
    | t == Throw = solve (i+1) (h-n) ns