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

D = sorted([list(map(int,input().split())) for n in range(N)])

mon = 0

num = 0



for n in range(N):

  mon+=D[n][0]*D[n][1]

  num+=D[n][1]

  

  if M<=num:

    print((mon-D[n][0]*(num-M)))

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

D = sorted([list(map(int,input().split())) for n in range(N)])

ans = 0

num = 0



for a,b in D:

  num+=b

  ans+=a*b

  if M<=num:

    ans-=a*(num-M)

    break



print(ans)
N, M = list(map(int, input().split()))
D = sorted([list(map(int, input().split())) for n in range(N)])
mon = 0
num = 0
for n in range(N):
    mon += D[n][0] * D[n][1]
    num += D[n][1]
    if M <= num:
        print((mon - D[n][0] * (num - M)))
        break

N, M = list(map(int, input().split()))
D = sorted([list(map(int, input().split())) for n in range(N)])
ans = 0
num = 0
for a, b in D:
    num += b
    ans += a * b
    if M <= num:
        ans -= a * (num - M)
        break
print(ans)

-mon = 0 +ans = 0 -for n in range(N): -    mon += D[n][0] * D[n][1] -    num += D[n][1] +for a, b in D: +    num += b +    ans += a * b -        print((mon - D[n][0] * (num - M))) +        ans -= a * (num - M) +print(ans)