N, T = gets.split.map(&:to_i)
AB = N.times.map { gets.split.map(&:to_i) }

dp = Array.new(N + 10) { Array.new(T + 3000 + 10, 0) }
N.times do |i|
  a, b = AB[i]
  (0...T).each do |j|
    v = dp[i][j]
    if v > dp[i + 1][j]
      dp[i + 1][j] = v
    end
    if v + b > dp[i + 1][j + a]
      dp[i + 1][j + a] = v + b
    end
  end
end
ans = dp[N].max
puts ans