n, m = $stdin.gets.split.map(&:to_i)
tasks = (1..n).map { $stdin.gets.split.map(&:to_i) }
tasks.sort!{|a,b| (b[0]*b[1] <=> a[0]*a[1]).nonzero? || (a[0] <=> b[0]) }

res = 0
m += 1
while m > 0  
  task = tasks.shift
  break unless task
  res += task[1]
  m -= task[0]
end
puts res
