f = lambda : list(map(int,input().split()))

n,m = f()

ll = sorted([list(f()) for _ in range(n)])

ans = 0

for p, c in ll:

  ans += p*min(m,c)

  m -= c

  if m < 1:

    break

print(ans)
f=lambda:list(map(int,input().split()))

n,m=f()

l=[]

for _ in range(n):

  l+=[tuple(f())]

l.sort()

c=0

for a,b in l:

  if b<m:

    m-=b

    c+=a*b

  else:

    c+=a*m

    break

print(c)
f = lambda: list(map(int, input().split()))
n, m = f()
ll = sorted([list(f()) for _ in range(n)])
ans = 0
for p, c in ll:
    ans += p * min(m, c)
    m -= c
    if m < 1:
        break
print(ans)

f = lambda: list(map(int, input().split()))
n, m = f()
l = []
for _ in range(n):
    l += [tuple(f())]
l.sort()
c = 0
for a, b in l:
    if b < m:
        m -= b
        c += a * b
    else:
        c += a * m
        break
print(c)

-ll = sorted([list(f()) for _ in range(n)]) -ans = 0 -for p, c in ll: -    ans += p * min(m, c) -    m -= c -    if m < 1: +l = [] +for _ in range(n): +    l += [tuple(f())] +l.sort() +c = 0 +for a, b in l: +    if b < m: +        m -= b +        c += a * b +    else: +        c += a * m -print(ans) +print(c)