import qualified Data.ByteString.Char8 as B
import Data.List
import qualified Data.Vector.Unboxed as V
readIntPair :: B.ByteString -> (Int,Int)
readIntPair s = p
    where
    Just p = do
        (n1, s') <- B.readInt s
        (n2, _ ) <- B.readInt (B.tail s')
        return (n1,n2)

(&) :: a -> (a -> b) -> b
(&) a b = b a

infixl 1 &

main :: IO ()
main = do
    (n,w_limit) <- fmap readIntPair B.getLine
    items <- fmap (map readIntPair . B.lines) B.getContents 
    let v_limit = 1000 * n + 1
        v_end = items 
                    & foldl' step s0 
                    & V.findIndices (<=w_limit) 
                    & V.maximum
        inf = w_limit + 1
        step :: V.Vector Int -> (Int, Int) -> V.Vector Int
        step tbl (wi, vi) = tbl'
            where
            tbl' = V.generate v_limit $ \v -> 
                    min (tbl V.! v) 
                        (if v >= vi then (tbl V.! (v - vi)) + wi 
                                    else w_limit+1)
        s0 = V.generate v_limit $ \i -> if i == 0 then 0 else inf
    print (v_end :: Int)
    
