require 'pp'
n, w = gets.split.map(&:to_i)
wv = []
n.times do
  wv << gets.split.map(&:to_i)
end
wv.sort_by! { |y| y[1] }
INF = 10 ** 10
dp = Array.new(1001, INF)
dp[0] = 0
wv.each do |tw, tv|
  1000.downto(tv).each do |cv|
    dp[cv] = dp[cv-tv] + tw if dp[cv] > dp[cv-tv] + tw
  end
end
pp dp.map.with_index(0){ |di, idx| [di, idx] }.reject{ |set| set[0] > w }.last[1]