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

k=M

s=0

A=[list(map(int,input().split())) for i in range(N)]

A=sorted(A,key=lambda x:x[0])

while k>0:

  for i in range(N):

    if k>A[i][1]:

      s+=A[i][0]*A[i][1]

      k=k-A[i][1]

    else:

      s+=A[i][0]*k

      k=0

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

A=[list(map(int,input().split())) for i in range(N)]

A=sorted(A,key=lambda x:x[0])

s=0 #本数

t=0 #値段

for i in range(N):

  s+=A[i][1]

  if M>s:

    t+=A[i][0]*A[i][1]

  else:

    over=s-M

    t+=A[i][0]*A[i][1]-A[i][0]*over

    break

print(t)
N, M = list(map(int, input().split()))
k = M
s = 0
A = [list(map(int, input().split())) for i in range(N)]
A = sorted(A, key=lambda x: x[0])
while k > 0:
    for i in range(N):
        if k > A[i][1]:
            s += A[i][0] * A[i][1]
            k = k - A[i][1]
        else:
            s += A[i][0] * k
            k = 0
print(s)

N, M = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
A = sorted(A, key=lambda x: x[0])
s = 0  # 本数
t = 0  # 値段
for i in range(N):
    s += A[i][1]
    if M > s:
        t += A[i][0] * A[i][1]
    else:
        over = s - M
        t += A[i][0] * A[i][1] - A[i][0] * over
        break
print(t)

-k = M -s = 0 -while k > 0: -    for i in range(N): -        if k > A[i][1]: -            s += A[i][0] * A[i][1] -            k = k - A[i][1] -        else: -            s += A[i][0] * k -            k = 0 -print(s) +s = 0  # 本数 +t = 0  # 値段 +for i in range(N): +    s += A[i][1] +    if M > s: +        t += A[i][0] * A[i][1] +    else: +        over = s - M +        t += A[i][0] * A[i][1] - A[i][0] * over +        break +print(t)