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,*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-=t

  if m<=0:

    print(ans)

    break
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, *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 -= t
    if m <= 0:
        print(ans)
        break

-    m = max(m - t, 0) -    if not m: +    m -= t +    if m <= 0: +        print(ans) -print(ans)