import numpy as np 



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

AB = []

for i in range(N):

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

    AB.append([a,b])



need = M

cost = 0



AB.sort()



for i in range(N):

    if need - AB[i][1] >= 0:

        need -= AB[i][1]

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

    else:

        cost += AB[i][0]*need 

        break    



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



C = []

for i in range(N):

    C.append(tuple(map(int,input().split())))



C.sort()



tmp = M

ans = 0

for cost,num in C:

    if tmp - num >= 0:##全部買う

        tmp -= num

        ans += num*cost

    else:

        ans += cost*tmp

        break



print(ans)
import numpy as np

N, M = list(map(int, input().split()))
AB = []
for i in range(N):
    a, b = list(map(int, input().split()))
    AB.append([a, b])
need = M
cost = 0
AB.sort()
for i in range(N):
    if need - AB[i][1] >= 0:
        need -= AB[i][1]
        cost += AB[i][0] * AB[i][1]
    else:
        cost += AB[i][0] * need
        break
print(cost)

N, M = list(map(int, input().split()))
C = []
for i in range(N):
    C.append(tuple(map(int, input().split())))
C.sort()
tmp = M
ans = 0
for cost, num in C:
    if tmp - num >= 0:  ##全部買う
        tmp -= num
        ans += num * cost
    else:
        ans += cost * tmp
        break
print(ans)

-import numpy as np - -AB = [] +C = [] -    a, b = list(map(int, input().split())) -    AB.append([a, b]) -need = M -cost = 0 -AB.sort() -for i in range(N): -    if need - AB[i][1] >= 0: -        need -= AB[i][1] -        cost += AB[i][0] * AB[i][1] +    C.append(tuple(map(int, input().split()))) +C.sort() +tmp = M +ans = 0 +for cost, num in C: +    if tmp - num >= 0:  ##全部買う +        tmp -= num +        ans += num * cost -        cost += AB[i][0] * need +        ans += cost * tmp -print(cost) +print(ans)