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

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

X.sort()



ans = 0

res = M

for v in X:

    ans += v[0] * min(v[1], res)

    res -= v[1]

    if res <= 0:

        break

        

print(ans)



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

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



X.sort()

res = M

ans = 0

for a, b in X:

    if res <= 0:

        break



    tmp = min(b, res)

    res -= tmp

    ans += tmp * a



print(ans)

N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
X.sort()
ans = 0
res = M
for v in X:
    ans += v[0] * min(v[1], res)
    res -= v[1]
    if res <= 0:
        break
print(ans)

N, M = list(map(int, input().split()))
X = [list(map(int, input().split())) for _ in range(N)]
X.sort()
res = M
ans = 0
for a, b in X:
    if res <= 0:
        break
    tmp = min(b, res)
    res -= tmp
    ans += tmp * a
print(ans)

+res = M -res = M -for v in X: -    ans += v[0] * min(v[1], res) -    res -= v[1] +for a, b in X: +    tmp = min(b, res) +    res -= tmp +    ans += tmp * a