import itertools

import math

import fractions

import functools

import copy

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

ab = []

for i in range(n):

    ab.append(list(map(int, input().split())))



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



yen = 0

amount = 0

index = 0

for i in range(n):

    if amount < m:

        yen += ab[i][0] * ab[i][1]

        amount += ab[i][1]

        index = i

    else: break

b = 0

for i in range(index):

    b += ab[i][1]

print((yen - ab[index][1]*ab[index][0] + ab[index][0]*(m-b)))

def main():

    # n = int(input())

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

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

    # s = input()

    # h = [int(input()) for _ in rane(n)]



    ab = []

    for i in range(n):

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

        ab.append([a, b])



    cost = 0

    temp_i = 0

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

    for i in range(n):

        cost += ab[i][0] * ab[i][1]

        m -= ab[i][1]

        if m <= 0:

            temp_i = i

            break



    if m == 0:

        print(cost)

    elif m < 0:

        cost += ab[temp_i][0] * m

        print(cost)





if __name__ == '__main__':

    main()

import itertools
import math
import fractions
import functools
import copy

n, m = list(map(int, input().split()))
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort(key=lambda x: x[0])
yen = 0
amount = 0
index = 0
for i in range(n):
    if amount < m:
        yen += ab[i][0] * ab[i][1]
        amount += ab[i][1]
        index = i
    else:
        break
b = 0
for i in range(index):
    b += ab[i][1]
print((yen - ab[index][1] * ab[index][0] + ab[index][0] * (m - b)))

def main():
    # n = int(input())
    n, m = list(map(int, input().split()))
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]
    ab = []
    for i in range(n):
        a, b = list(map(int, input().split()))
        ab.append([a, b])
    cost = 0
    temp_i = 0
    ab.sort(key=lambda x: x[0])
    for i in range(n):
        cost += ab[i][0] * ab[i][1]
        m -= ab[i][1]
        if m <= 0:
            temp_i = i
            break
    if m == 0:
        print(cost)
    elif m < 0:
        cost += ab[temp_i][0] * m
        print(cost)


if __name__ == "__main__":
    main()

-import itertools -import math -import fractions -import functools -import copy +def main(): +    # n = int(input()) +    n, m = list(map(int, input().split())) +    # a = list(map(int, input().split())) +    # s = input() +    # h = [int(input()) for _ in rane(n)] +    ab = [] +    for i in range(n): +        a, b = list(map(int, input().split())) +        ab.append([a, b]) +    cost = 0 +    temp_i = 0 +    ab.sort(key=lambda x: x[0]) +    for i in range(n): +        cost += ab[i][0] * ab[i][1] +        m -= ab[i][1] +        if m <= 0: +            temp_i = i +            break +    if m == 0: +        print(cost) +    elif m < 0: +        cost += ab[temp_i][0] * m +        print(cost) -n, m = list(map(int, input().split())) -ab = [] -for i in range(n): -    ab.append(list(map(int, input().split()))) -ab.sort(key=lambda x: x[0]) -yen = 0 -amount = 0 -index = 0 -for i in range(n): -    if amount < m: -        yen += ab[i][0] * ab[i][1] -        amount += ab[i][1] -        index = i -    else: -        break -b = 0 -for i in range(index): -    b += ab[i][1] -print((yen - ab[index][1] * ab[index][0] + ab[index][0] * (m - b))) + +if __name__ == "__main__": +    main()