WV = $<.read.split.map(&:to_i).each_slice(2).to_a
N,W = WV.shift
WV.map! {|w,v| [1.0*w/v,w,v] if w<=W }.compact!
WV.sort!
A = Array.new W+1
m = 0
WV.each_with_index {|(*,w,_),i|
  next  if A[w]
  s=t = 0
  WV[i..-1].each_with_index {|(*,w,v),j|
    if !A[w+=s] && W>=w
      A[s=w] = j
      t += v
    end
  }
  m = t  if m < t
}
p m