n, mw = gets.chomp.split.map(&:to_i)
sum = []
w, v = gets.chomp.split.map(&:to_i)
v_sum = v
v.times do |i|
  sum[i+1] = w
end

(n-1).times do
  w, v = gets.chomp.split.map(&:to_i)
  v_sum += v
  v_sum.downto(1) do |i|
    if !sum[i] && i > v
      sum[i] = sum[i-v] + w
    elsif i > v
      sum[i] = sum[i-v] + w if sum[i-v] + w < sum[i]
    elsif !sum[i]
      sum[i] = w
    else
      sum[i] = w if w < sum[i]
    end
  end
end

#p sum

v_sum.downto(1) do |i|
  if sum[i] <= mw
    puts i
    exit
  end
end
