n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Hash.new(Float::INFINITY)
dp[0] = 0
items.each do |w, v|
  dp.dup.each do |pv, pw|
    nw = pw + w
    nv = pv + v
    dp[nv] = nw if nw <= w_max && dp[nv] > nw
  end
end
puts dp.keys.max
