N, W = gets.split.map(&:to_i)
items = (1..N).map { gets.split.map(&:to_i) }
upper_bound = items.map(&:first).inject(:+)
min_weight = [0] + (1..upper_bound).map { Float::INFINITY }
items.each do |v, w|
  new_min_weight = min_weight.dup
  (v..upper_bound).each do |value|
    new_min_weight[value] = min_weight[value - v] + w if min_weight[value - v] + w < new_min_weight[value]
  end
  min_weight = new_min_weight
end
upper_bound.downto(0) do |value|
  if min_weight[value] <= W
    p value
    break
  end
end
