n, t = gets.chomp.split.map(&:to_i)
dp = Array.new(n + 1) { Hash.new(0) }
dp[0][t] = 0
res = [0]

n.times do |w|
  a, b = gets.chomp.split.map(&:to_i)
  k = dp[w].keys
  k.each do |rt|
    next if rt <= 0
    dp[w + 1][rt] = [dp[w + 1][rt], dp[w][rt]].max      
    dp[w + 1][rt - a] = [dp[w + 1][rt - a], dp[w][rt] + b].max
  end
  res << dp[w + 1].values.max
end
puts res.max