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

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



AB.sort(key=lambda x: x[0])

ans = 0

for i in range(N):

    if M >= AB[i][1]:

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

        M -= AB[i][1]

    else:

        ans += AB[i][0] * M

        M = 0

    if M == 0:

        break

print(ans)

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

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

AB.sort()



ans = 0

for a, b in AB:

    if M > b:

        M -= b

        ans += a*b

    else:

        ans += a*M

        break



print(ans)

N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
ans = 0
for i in range(N):
    if M >= AB[i][1]:
        ans += AB[i][0] * AB[i][1]
        M -= AB[i][1]
    else:
        ans += AB[i][0] * M
        M = 0
    if M == 0:
        break
print(ans)

N, M = list(map(int, input().split()))
AB = [tuple(map(int, input().split())) for i in range(N)]
AB.sort()
ans = 0
for a, b in AB:
    if M > b:
        M -= b
        ans += a * b
    else:
        ans += a * M
        break
print(ans)

-AB = [list(map(int, input().split())) for i in range(N)] -AB.sort(key=lambda x: x[0]) +AB = [tuple(map(int, input().split())) for i in range(N)] +AB.sort() -for i in range(N): -    if M >= AB[i][1]: -        ans += AB[i][0] * AB[i][1] -        M -= AB[i][1] +for a, b in AB: +    if M > b: +        M -= b +        ans += a * b -        ans += AB[i][0] * M -        M = 0 -    if M == 0: +        ans += a * M