n, W = gets.chomp.split.map(&:to_i)

v_max = 15
dp = Array.new(v_max+1,Float::INFINITY) # v value vをweight wで出せる

n.times do |i|
  w, v = gets.chomp.split.map(&:to_i)
#  v_max.downto(0).each do |value|
  0.upto(v_max).each do |value|
    if  value <= v
      dp[value] = dp[value-v] + w if dp[value] < dp[value-v] + w
    end
  end
  p dp
end

# p dp
p dp.select!{|e| e <= W}
puts dp.count