Item = Struct.new(:w, :v)

n, w = gets.split.map(&:to_i)
items = n.times.map {Item[*gets.split.map(&:to_i)]}

dp = Array.new(1001, 10000000000)
dp1 = Array.new(1001, 10000000000)

dp1[0] = 0

(1..n).each do |i|
	item = items[i-1]
	(0..1000).each do |u|
		# dp[i][u] =
		# a. 実現不可能なら∞
		# b. 実現可能なら min{dp1[u-item.v] + item.w, dp1[u]}
		_w = dp[u] = [
			u >= item.v ? dp1[u-item.v] + item.w : 10000000000,
			dp1[u]
		].min
	end
	
	dp, dp1 = dp1, dp
end

v = dp1.rindex { |_| _ <= w }
#puts dp1[w]
p v
