import numpy as np

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

AB = np.empty((N, 2), dtype=np.int64)

for n in range(N):

    AB[n, :] = list(map(int, input().split()))

AB = AB[AB[:, 0].argsort(), :]

n = 0

ans = 0

while M > 0:

    if M > AB[n, 1]:

        ans += AB[n, 0] * AB[n, 1]

        M -= AB[n, 1]

    else:

        ans += AB[n, 0] * M

        M = 0

    n += 1

print(ans)
import numpy as np

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

a=np.zeros(n)

b=np.zeros(n)

for i in range(n):

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

x=np.argsort(a)

ans=0

i=0

while m>0:

    ans+=a[x[i]]*min(b[x[i]],m)

    m-=b[x[i]]

    i+=1

print((int(ans)))
import numpy as np

N, M = list(map(int, input().split()))
AB = np.empty((N, 2), dtype=np.int64)
for n in range(N):
    AB[n, :] = list(map(int, input().split()))
AB = AB[AB[:, 0].argsort(), :]
n = 0
ans = 0
while M > 0:
    if M > AB[n, 1]:
        ans += AB[n, 0] * AB[n, 1]
        M -= AB[n, 1]
    else:
        ans += AB[n, 0] * M
        M = 0
    n += 1
print(ans)

import numpy as np

n, m = list(map(int, input().split()))
a = np.zeros(n)
b = np.zeros(n)
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
x = np.argsort(a)
ans = 0
i = 0
while m > 0:
    ans += a[x[i]] * min(b[x[i]], m)
    m -= b[x[i]]
    i += 1
print((int(ans)))

-N, M = list(map(int, input().split())) -AB = np.empty((N, 2), dtype=np.int64) -for n in range(N): -    AB[n, :] = list(map(int, input().split())) -AB = AB[AB[:, 0].argsort(), :] -n = 0 +n, m = list(map(int, input().split())) +a = np.zeros(n) +b = np.zeros(n) +for i in range(n): +    a[i], b[i] = list(map(int, input().split())) +x = np.argsort(a) -while M > 0: -    if M > AB[n, 1]: -        ans += AB[n, 0] * AB[n, 1] -        M -= AB[n, 1] -    else: -        ans += AB[n, 0] * M -        M = 0 -    n += 1 -print(ans) +i = 0 +while m > 0: +    ans += a[x[i]] * min(b[x[i]], m) +    m -= b[x[i]] +    i += 1 +print((int(ans)))