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

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

AB.sort()

cost = 0

while M > 0:

  if AB[0][1] < M:

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

    M=M-AB[0][1]

    AB.pop(0)

  else:

    cost = cost + AB[0][0]*M

    M = 0

    

print(cost)

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

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

S.sort()

ans = 0

k = M

for i in range(N):

  if k == 0:

    break

  elif S[i][1] <= k:

    k -= S[i][1]

    ans += S[i][0] * S[i][1]

  else:

    ans += S[i][0] * k

    k = 0

print(ans)
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()
cost = 0
while M > 0:
    if AB[0][1] < M:
        cost = cost + AB[0][0] * AB[0][1]
        M = M - AB[0][1]
        AB.pop(0)
    else:
        cost = cost + AB[0][0] * M
        M = 0
print(cost)

N, M = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(N)]
S.sort()
ans = 0
k = M
for i in range(N):
    if k == 0:
        break
    elif S[i][1] <= k:
        k -= S[i][1]
        ans += S[i][0] * S[i][1]
    else:
        ans += S[i][0] * k
        k = 0
print(ans)

-AB = [list(map(int, input().split())) for i in range(N)] -AB.sort() -cost = 0 -while M > 0: -    if AB[0][1] < M: -        cost = cost + AB[0][0] * AB[0][1] -        M = M - AB[0][1] -        AB.pop(0) +S = [list(map(int, input().split())) for i in range(N)] +S.sort() +ans = 0 +k = M +for i in range(N): +    if k == 0: +        break +    elif S[i][1] <= k: +        k -= S[i][1] +        ans += S[i][0] * S[i][1] -        cost = cost + AB[0][0] * M -        M = 0 -print(cost) +        ans += S[i][0] * k +        k = 0 +print(ans)