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) { Float::INFINITY } }
dp[0][0] = 0

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

puts dp[n].rindex { |e| e <= lw }
