N, W = gets.split.map(&:to_i)
WV = N.times.map{gets.split.map(&:to_i)}.sort_by{|a|[a[0], a[1]]}
#N = 100
#W = 10 ** 9
#WV = N.times.map{[rand(1..W-1), rand(1..10**3)]}.sort_by{|a|[a[0], a[1]]}

dp = Hash.new(Float::INFINITY)
dp[0] = 0
que = [0]

WV.each do |w, v|
  dp_dup = dp.dup
  dp_dup.each do |dp_v, dp_w|
    nw, nv = w + dp_w, v + dp_v
    next if nw > W
    
    if dp[nv] > nw
      dp[nv] = nw
    end
  end
end
p dp.keys.max
