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

cost = []

for i in range(n):

    a,b = list(map(int,input().split()))

    cost.append([a,b])

cost.sort()

cnt = 0

price = 0

for i in range(n):

    if cnt + cost[i][1] <= m:

        price += cost[i][0] * cost[i][1]

        cnt += cost[i][1]

    else:

        price += (m-cnt)*cost[i][0]

        print(price)

        exit()

print(price)

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

drink = []

for i in range(n):

    a,b = list(map(int,input().split()))

    drink.append((a,b))

drink.sort()

ans = 0

for i in range(n):

    if m == 0:

        break

    if m >= drink[i][1]:

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

        m -= drink[i][1]

    else:

        ans += m*drink[i][0]

        m = 0

print(ans)

n, m = list(map(int, input().split()))
cost = []
for i in range(n):
    a, b = list(map(int, input().split()))
    cost.append([a, b])
cost.sort()
cnt = 0
price = 0
for i in range(n):
    if cnt + cost[i][1] <= m:
        price += cost[i][0] * cost[i][1]
        cnt += cost[i][1]
    else:
        price += (m - cnt) * cost[i][0]
        print(price)
        exit()
print(price)

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

-cost = [] +drink = [] -    cost.append([a, b]) -cost.sort() -cnt = 0 -price = 0 +    drink.append((a, b)) +drink.sort() +ans = 0 -    if cnt + cost[i][1] <= m: -        price += cost[i][0] * cost[i][1] -        cnt += cost[i][1] +    if m == 0: +        break +    if m >= drink[i][1]: +        ans += drink[i][0] * drink[i][1] +        m -= drink[i][1] -        price += (m - cnt) * cost[i][0] -        print(price) -        exit() -print(price) +        ans += m * drink[i][0] +        m = 0 +print(ans)