N,M = list(map(int,input().split()))

ab = []

for i in range(N):

  ab += [list(map(int,input().split()))]

ab.sort()

rest = M

cost = 0

while True:

  if rest - ab[0][1] <= 0:

    cost += rest * ab[0][0]

    break

  else:

    rest -= ab[0][1]

    cost += ab[0][0] * ab[0][1]

    del ab[0]

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

ab = []

for _ in range(n):

  ab.append(list(map(int,input().split())))

ab.sort()

ans = 0

for i in range(n):

  a,b = ab[i]

  if m > b:

    m -= b

    ans += a * b

  else:

    ans += a * m

    break

  #print(m,ans)

print(ans)
N, M = list(map(int, input().split()))
ab = []
for i in range(N):
    ab += [list(map(int, input().split()))]
ab.sort()
rest = M
cost = 0
while True:
    if rest - ab[0][1] <= 0:
        cost += rest * ab[0][0]
        break
    else:
        rest -= ab[0][1]
        cost += ab[0][0] * ab[0][1]
        del ab[0]
print(cost)

n, m = list(map(int, input().split()))
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
ans = 0
for i in range(n):
    a, b = ab[i]
    if m > b:
        m -= b
        ans += a * b
    else:
        ans += a * m
        break
    # print(m,ans)
print(ans)

-N, M = list(map(int, input().split())) +n, m = list(map(int, input().split())) -for i in range(N): -    ab += [list(map(int, input().split()))] +for _ in range(n): +    ab.append(list(map(int, input().split()))) -rest = M -cost = 0 -while True: -    if rest - ab[0][1] <= 0: -        cost += rest * ab[0][0] +ans = 0 +for i in range(n): +    a, b = ab[i] +    if m > b: +        m -= b +        ans += a * b +    else: +        ans += a * m -    else: -        rest -= ab[0][1] -        cost += ab[0][0] * ab[0][1] -        del ab[0] -print(cost) +    # print(m,ans) +print(ans)