import Control.Monad
import Data.List

type Item = (Int,Int)

readInts :: IO [Int]
readInts = fmap (map read . words) getLine

readItem :: IO Item
readItem = do 
  [x, y] <- readInts
  return (x, y)

unit :: Item -> Item -> Ordering
unit a b 
  | ua > ub   = LT
  | ua < ub   = GT
  | otherwise = EQ
  where
    ua = (fromIntegral $ fst a)/(fromIntegral $ snd a)
    ub = (fromIntegral $ fst b)/(fromIntegral $ snd b)

gks :: [Item] -> Int -> Double
gks ls wgt = iter ls wgt 0.0 where
  iter [] _ ac = ac
  iter _  0 ac = ac
  iter ((v, w):xs) wgt ac
    | wgt < w   = ac +  (fromIntegral v)/(fromIntegral w)*(fromIntegral wgt)
    | otherwise = iter xs (wgt-w) ac + fromIntegral v

solver :: [Item] -> Int -> Int
solver [] _ = 0
solver _  0 = 0
solver ((v, w):xs) weight
  | weight >= w && (fromIntegral v0) <  v1 = max v0 (solver xs weight) 
  | weight >= w && (fromIntegral v0) >= v1 = v0
  | otherwise = solver xs weight
  where
    v0 = solver xs (weight-w) + v
    v1 = gks xs weight

main :: IO ()
main = do
  [n,w] <- readInts
  ls <- replicateM n readItem
  let items = sortBy unit ls
  print (solver items w)
  
