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

shops = [None] * N

for i in range(N):

  shops[i] = list(map(int, input().split()))

shops.sort()

cnt = 0

ans = 0

while cnt < M:

  shop = shops.pop(0)

  if cnt + shop[1] >= M:

    ans += (M - cnt) * shop[0]

    cnt = M

  else:

    ans += shop[0] * shop[1]

    cnt += shop[1]

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

shops = [None] * N

for i in range(N):

  shops[i] = list(map(int, input().split()))

shops.sort()

cnt = 0

ans = 0

for i in range(N):

  shop = shops[i]

  ans += shop[0] * shop[1]

  cnt += shop[1]

  if cnt > M:

    ans -= (cnt - M) * shop[0]

    break

print(ans)
N, M = list(map(int, input().split()))
shops = [None] * N
for i in range(N):
    shops[i] = list(map(int, input().split()))
shops.sort()
cnt = 0
ans = 0
while cnt < M:
    shop = shops.pop(0)
    if cnt + shop[1] >= M:
        ans += (M - cnt) * shop[0]
        cnt = M
    else:
        ans += shop[0] * shop[1]
        cnt += shop[1]
print(ans)

N, M = list(map(int, input().split()))
shops = [None] * N
for i in range(N):
    shops[i] = list(map(int, input().split()))
shops.sort()
cnt = 0
ans = 0
for i in range(N):
    shop = shops[i]
    ans += shop[0] * shop[1]
    cnt += shop[1]
    if cnt > M:
        ans -= (cnt - M) * shop[0]
        break
print(ans)

-while cnt < M: -    shop = shops.pop(0) -    if cnt + shop[1] >= M: -        ans += (M - cnt) * shop[0] -        cnt = M -    else: -        ans += shop[0] * shop[1] -        cnt += shop[1] +for i in range(N): +    shop = shops[i] +    ans += shop[0] * shop[1] +    cnt += shop[1] +    if cnt > M: +        ans -= (cnt - M) * shop[0] +        break