

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

A = [list(map(int, input().split())) for _ in range(N)]



A.sort(key=lambda x: x[0])



total = 0

remain = M

for x in A:

    yen, num = x

    purchase = min(num, remain)

    total += (yen * purchase)

    remain -= purchase

    if remain == 0:

        print(total)

        exit()


import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**6)

##############################



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

AB = []

for i in range(N):

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

    AB.append([a, b])



AB.sort()



ans = 0

for (yen, num) in AB:

    if num <= M:

        ans += (yen * num)

        M -= num

    else:

        ans += (yen * M)

        print(ans)

        exit()



print(ans)
N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x: x[0])
total = 0
remain = M
for x in A:
    yen, num = x
    purchase = min(num, remain)
    total += yen * purchase
    remain -= purchase
    if remain == 0:
        print(total)
        exit()

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
N, M = list(map(int, input().split()))
AB = []
for i in range(N):
    a, b = list(map(int, input().split()))
    AB.append([a, b])
AB.sort()
ans = 0
for (yen, num) in AB:
    if num <= M:
        ans += yen * num
        M -= num
    else:
        ans += yen * M
        print(ans)
        exit()
print(ans)

+import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**6) +############################## -A = [list(map(int, input().split())) for _ in range(N)] -A.sort(key=lambda x: x[0]) -total = 0 -remain = M -for x in A: -    yen, num = x -    purchase = min(num, remain) -    total += yen * purchase -    remain -= purchase -    if remain == 0: -        print(total) +AB = [] +for i in range(N): +    a, b = list(map(int, input().split())) +    AB.append([a, b]) +AB.sort() +ans = 0 +for (yen, num) in AB: +    if num <= M: +        ans += yen * num +        M -= num +    else: +        ans += yen * M +        print(ans) +print(ans)