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

e = []

for _ in range(N):

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

    e.append([a, b])



e = list(sorted(e, key=lambda x: x[0]))

# 安値から



cost = 0

cnt = M

e_i = 0

while cnt > 0:

    can_buy = min(cnt, e[e_i][1])

    # 必要本数か売っている本数のうち少ない方



    cost += can_buy * e[e_i][0]

    e[e_i][1] -= can_buy

    cnt -= can_buy

    if e[e_i][1] == 0:

        e_i += 1



print(cost)

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

e = [tuple(map(int, input().split())) for _ in range(n)]

e.sort()  # 金額昇順

ans = 0

rest = m

for a, b in e:

    use = min(rest, b)

    ans += use * a

    rest -= use

    if rest == 0:

        break

print(ans)

N, M = list(map(int, input().split()))
e = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    e.append([a, b])
e = list(sorted(e, key=lambda x: x[0]))
# 安値から
cost = 0
cnt = M
e_i = 0
while cnt > 0:
    can_buy = min(cnt, e[e_i][1])
    # 必要本数か売っている本数のうち少ない方
    cost += can_buy * e[e_i][0]
    e[e_i][1] -= can_buy
    cnt -= can_buy
    if e[e_i][1] == 0:
        e_i += 1
print(cost)

n, m = list(map(int, input().split()))
e = [tuple(map(int, input().split())) for _ in range(n)]
e.sort()  # 金額昇順
ans = 0
rest = m
for a, b in e:
    use = min(rest, b)
    ans += use * a
    rest -= use
    if rest == 0:
        break
print(ans)

-N, M = list(map(int, input().split())) -e = [] -for _ in range(N): -    a, b = list(map(int, input().split())) -    e.append([a, b]) -e = list(sorted(e, key=lambda x: x[0])) -# 安値から -cost = 0 -cnt = M -e_i = 0 -while cnt > 0: -    can_buy = min(cnt, e[e_i][1]) -    # 必要本数か売っている本数のうち少ない方 -    cost += can_buy * e[e_i][0] -    e[e_i][1] -= can_buy -    cnt -= can_buy -    if e[e_i][1] == 0: -        e_i += 1 -print(cost) +n, m = list(map(int, input().split())) +e = [tuple(map(int, input().split())) for _ in range(n)] +e.sort()  # 金額昇順 +ans = 0 +rest = m +for a, b in e: +    use = min(rest, b) +    ans += use * a +    rest -= use +    if rest == 0: +        break +print(ans)