n, lw = gets.split.map(&:to_i)
w, v = Array.new(n) { gets.split.map(&:to_i) }.transpose
lv = v.sum
dp = Array.new(lv + 1) { Float::INFINITY }
dp[0] = cv = 0

n.times do |i|
  cv = [cv + v[i], lv].min

  cv.downto(v[i]) { |e| dp[e] = [dp[e], dp[e - v[i]] + w[i]].min }
end

puts dp.rindex { |e| e <= lw }
