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

drink = []

for _ in range(N):

    a , b = list(map(int,input().split()))

    drink.append([a,b])

drink.sort()





value = 0

hold = 0

while hold != M:

    if drink[0][1] == 0:

        drink.pop(0)

    value += drink[0][0]

    hold += 1

    drink[0][1] -= 1

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

shops = list(list(map(int, input().split())) for _ in range(N))

shops.sort()

ans = 0

for value, count in shops:

    tmp_M = max(M - count , 0)

    ans += (M - tmp_M) * value

    M = tmp_M

    if M == 0:

        break

print(ans)

N, M = list(map(int, input().split()))
drink = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    drink.append([a, b])
drink.sort()
value = 0
hold = 0
while hold != M:
    if drink[0][1] == 0:
        drink.pop(0)
    value += drink[0][0]
    hold += 1
    drink[0][1] -= 1
print(value)

N, M = list(map(int, input().split()))
shops = list(list(map(int, input().split())) for _ in range(N))
shops.sort()
ans = 0
for value, count in shops:
    tmp_M = max(M - count, 0)
    ans += (M - tmp_M) * value
    M = tmp_M
    if M == 0:
        break
print(ans)

-drink = [] -for _ in range(N): -    a, b = list(map(int, input().split())) -    drink.append([a, b]) -drink.sort() -value = 0 -hold = 0 -while hold != M: -    if drink[0][1] == 0: -        drink.pop(0) -    value += drink[0][0] -    hold += 1 -    drink[0][1] -= 1 -print(value) +shops = list(list(map(int, input().split())) for _ in range(N)) +shops.sort() +ans = 0 +for value, count in shops: +    tmp_M = max(M - count, 0) +    ans += (M - tmp_M) * value +    M = tmp_M +    if M == 0: +        break +print(ans)