n, m = gets.split.map(&:to_i)
abs = []
n.times do |i|
  abs << gets.split.map(&:to_i)
end

# abs.sort_by! { |a, b| [-b, -a] }
# abs.sort_by! { |a, b| [-a, -b] }
abs.sort_by! { |a, b| [-a*b] }

# puts abs.inspect

ans = 0

c = 0
d = 0
while d <= m && c <= n-1 do
  ab = abs[c]
  a = ab[0]
  b = ab[1]

  if a + d <= m
    ans += b
    d += 1
  end

  # puts ans

  c += 1
end

puts ans