from sys import stdin



n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]



li.sort(key=lambda x:(x[0],x[1]))

cost = 0



while m > 0:

    if li[0][1] > 0:

        cost += li[0][0]

        li[0][1] -= 1

        m -= 1

    else:

        li.pop(0)



print(cost)
from sys import stdin

n,m = list(map(int,stdin.readline().rstrip().split()))

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

li.sort()



yen = 0



for i in li:

    j,k = i

    if k >= m:

        yen += j*m

        break

    yen += j*k

    m -= k



print(yen)
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
li.sort(key=lambda x: (x[0], x[1]))
cost = 0
while m > 0:
    if li[0][1] > 0:
        cost += li[0][0]
        li[0][1] -= 1
        m -= 1
    else:
        li.pop(0)
print(cost)

from sys import stdin

n, m = list(map(int, stdin.readline().rstrip().split()))
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
li.sort()
yen = 0
for i in li:
    j, k = i
    if k >= m:
        yen += j * m
        break
    yen += j * k
    m -= k
print(yen)

-n, m = [int(x) for x in stdin.readline().rstrip().split()] +n, m = list(map(int, stdin.readline().rstrip().split())) -li.sort(key=lambda x: (x[0], x[1])) -cost = 0 -while m > 0: -    if li[0][1] > 0: -        cost += li[0][0] -        li[0][1] -= 1 -        m -= 1 -    else: -        li.pop(0) -print(cost) +li.sort() +yen = 0 +for i in li: +    j, k = i +    if k >= m: +        yen += j * m +        break +    yen += j * k +    m -= k +print(yen)