n, lw = gets.split.map(&:to_i)
w, v = Array.new(n) { gets.split.map(&:to_i) }.transpose
lv = v.sum

dp = Array.new(n + 1) { Array.new(lv + 1) }
dp[0][0] = 0
1.upto(lv) { |e| dp[0][e] = Float::INFINITY }

1.upto(n) do |i|
  0.upto(lv) { |j| dp[i][j] = dp[i - 1][j] }
  v[i - 1].upto(lv) do |j|
    dp[i][j] = dp[i - 1][j - v[i - 1]] + w[i - 1] if dp[i - 1][j - v[i - 1]] + w[i - 1] <= [dp[i][j], lw].min
  end
end

puts 0.upto(lv).select { |e| dp[n][e] < Float::INFINITY }.max
