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

stores = []

for i in range(n):

    store = input().split()

    stores.append([int(store[i]) for i in range(2)])

stores.sort()



drinks = 0

cost = 0

for store in stores:

    if drinks + store[1] <= m:

        drinks += store[1]

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

    elif drinks + store[1] > m:

        cost += (m - drinks)*store[0]

        break

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

stores = [[int(j) for j in input().split()]for i in range(n)]

stores.sort()



drinks = 0

cost = 0

for store in stores:

    if drinks + store[1] <= m:

        drinks += store[1]

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

    elif drinks + store[1] > m:

        cost += (m - drinks)*store[0]

        break

print(cost)
n, m = list(map(int, input().split()))
stores = []
for i in range(n):
    store = input().split()
    stores.append([int(store[i]) for i in range(2)])
stores.sort()
drinks = 0
cost = 0
for store in stores:
    if drinks + store[1] <= m:
        drinks += store[1]
        cost += store[0] * store[1]
    elif drinks + store[1] > m:
        cost += (m - drinks) * store[0]
        break
print(cost)

n, m = list(map(int, input().split()))
stores = [[int(j) for j in input().split()] for i in range(n)]
stores.sort()
drinks = 0
cost = 0
for store in stores:
    if drinks + store[1] <= m:
        drinks += store[1]
        cost += store[0] * store[1]
    elif drinks + store[1] > m:
        cost += (m - drinks) * store[0]
        break
print(cost)

-stores = [] -for i in range(n): -    store = input().split() -    stores.append([int(store[i]) for i in range(2)]) +stores = [[int(j) for j in input().split()] for i in range(n)]