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

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

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

ans=0

for i in range(n):

  s,t=l[i]

  if m-t<=0:

    ans+=s*m

    break

  else:

    m-=t

    ans+=s*t

print(ans)
n,m,*l=list(map(int,open(0).read().split()))

ans=0

for s,t in sorted(zip(l[::2],l[1::2])):

  ans+=s*min(m,t)

  m=max(m-t,0)

  if not m:

    break

print(ans)
n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x: x[0])
ans = 0
for i in range(n):
    s, t = l[i]
    if m - t <= 0:
        ans += s * m
        break
    else:
        m -= t
        ans += s * t
print(ans)

n, m, *l = list(map(int, open(0).read().split()))
ans = 0
for s, t in sorted(zip(l[::2], l[1::2])):
    ans += s * min(m, t)
    m = max(m - t, 0)
    if not m:
        break
print(ans)

-n, m = list(map(int, input().split())) -l = [list(map(int, input().split())) for _ in range(n)] -l.sort(key=lambda x: x[0]) +n, m, *l = list(map(int, open(0).read().split())) -for i in range(n): -    s, t = l[i] -    if m - t <= 0: -        ans += s * m +for s, t in sorted(zip(l[::2], l[1::2])): +    ans += s * min(m, t) +    m = max(m - t, 0) +    if not m: -    else: -        m -= t -        ans += s * t