import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m = LI()
    lst = []
    for _ in range(n):
        a, b = LI()
        lst.append([a,b])

    lst.sort()

    ans = 0
    for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

    print(ans)   
main() import bisect,collections,copy,itertools,math,string bisect collections copy itertools math string import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS def main():
    n, m = LI()
    lst = []
    for _ in range(n):
        a, b = LI()
        lst.append([a,b])

    lst.sort()

    ans = 0
    for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

    print(ans)    main n, m = LI() n LI() LI m lst = [] lst [] for _ in range(n):
        a, b = LI()
        lst.append([a,b])

     _ range(n) range n a, b = LI() a LI() LI b lst.append([a,b]) lst.append lst append [a,b] a b lst.sort() lst.sort lst sort ans = 0 ans 0 for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

     i range(n) range n tem = lst[i][1] tem lst[i][1] [i] lst i 1 lst[i][1] = max(0, lst[i][1]-m) lst[i][1] [i] lst i 1 max(0, lst[i][1]-m) max 0 lst[i][1]-m lst[i][1] [i] lst i 1 m bought = tem-lst[i][1] bought tem-lst[i][1] tem lst[i][1] [i] lst i 1 m -= bought m bought ans += lst[i][0]*bought ans lst[i][0]*bought lst[i][0] [i] lst i 0 bought if m == 0:
            break

     m == 0 m 0 break print(ans) print ans main() main def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I def main():
    n, m = LI()
    lst = []
    for _ in range(n):
        a, b = LI()
        lst.append([a,b])

    lst.sort()

    ans = 0
    for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

    print(ans)    def main():
    n, m = LI()
    lst = []
    for _ in range(n):
        a, b = LI()
        lst.append([a,b])

    lst.sort()

    ans = 0
    for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

    print(ans)    main def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m = LI()
    lst = []
    for _ in range(n):
        a, b = LI()
        lst.append([a,b])

    lst.sort()

    ans = 0
    for i in range(n):
        tem = lst[i][1]
        lst[i][1] = max(0, lst[i][1]-m)
        bought = tem-lst[i][1]
        m -= bought
        ans += lst[i][0]*bought
        if m == 0:
            break

    print(ans)   
main()
