Item = Struct.new(:weight, :value)
n_items, limit_weight = (gets || "").split.map(&:to_i)
items = n_items.times.map { Item[*(gets || "").split.map(&:to_i)] }
max_value = items.max_by(&:value).value

=begin
価値を1つずつ増やしていき、重さの最小値がlimit_weightを越えたところで終了
dp[価値][番号] = 重さ
=end

dp = [[0] * 101]
max_sum_value = 0
1.step do |value|
  dp[value] = [Float::INFINITY]
  items.each_with_index do |item, index|
    weight = dp[value][index]
    if value >= item.value
    	weight = [weight, dp[value - item.value][index] + item.weight].min
    end
    dp[value][index+1] = weight
  end
  if dp[value][n_items] <= limit_weight
    max_sum_value = value
  elsif value - max_sum_value >= max_value
    puts max_sum_value
    exit
  end
end