n,m = list(map(int,input().split()))

AB = [[int(i) for i in input().split()] for j in range(n)]

AB.sort()

res = 0

for a,b in AB:

	m -= b

	if m >= 0:

		res += a*b

	else:

		m += b

		res += a*m

		break

print(res)

n,m = list(map(int,input().split()))

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

AB.sort()

res = 0

for a,b in AB:

    res += a*min(b,m)

    m -= b

    if m < 0:

        break 

print(res)
n, m = list(map(int, input().split()))
AB = [[int(i) for i in input().split()] for j in range(n)]
AB.sort()
res = 0
for a, b in AB:
    m -= b
    if m >= 0:
        res += a * b
    else:
        m += b
        res += a * m
        break
print(res)

n, m = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(n)]
AB.sort()
res = 0
for a, b in AB:
    res += a * min(b, m)
    m -= b
    if m < 0:
        break
print(res)

-AB = [[int(i) for i in input().split()] for j in range(n)] +AB = [list(map(int, input().split())) for i in range(n)] +    res += a * min(b, m) -    if m >= 0: -        res += a * b -    else: -        m += b -        res += a * m +    if m < 0: