from operator import itemgetter



n, m = list(map(int, input().split()))

ab = [list(map(int, input().split())) for _ in range(n)]



ab.sort(key=itemgetter(0))



result = 0

for e in ab:

  count = min(m, e[1])

  result += e[0] * count

  m = max(m-count, 0)

print(result)
n, m = [int(x) for x in input().split()]



a = sorted([[int(x) for x in input().split()] for _ in range(n)], key=lambda x: x[0])



result = 0

for x in a:

  cnt = min(m, x[1])

  result += x[0] * cnt

  m -= cnt

print(result)
from operator import itemgetter

n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=itemgetter(0))
result = 0
for e in ab:
    count = min(m, e[1])
    result += e[0] * count
    m = max(m - count, 0)
print(result)

n, m = [int(x) for x in input().split()]
a = sorted([[int(x) for x in input().split()] for _ in range(n)], key=lambda x: x[0])
result = 0
for x in a:
    cnt = min(m, x[1])
    result += x[0] * cnt
    m -= cnt
print(result)

-from operator import itemgetter - -n, m = list(map(int, input().split())) -ab = [list(map(int, input().split())) for _ in range(n)] -ab.sort(key=itemgetter(0)) +n, m = [int(x) for x in input().split()] +a = sorted([[int(x) for x in input().split()] for _ in range(n)], key=lambda x: x[0]) -for e in ab: -    count = min(m, e[1]) -    result += e[0] * count -    m = max(m - count, 0) +for x in a: +    cnt = min(m, x[1]) +    result += x[0] * cnt +    m -= cnt