program answer
  implicit none
  integer(8) :: i, N, M, sum, last, count
  integer(8), allocatable :: A(:), B(:)
  read(*,*) N, M
  allocate(A(N),B(N))
  do i = 1, N
     read(*,*) A(i), B(i)
  end do
  A(:)=A(:)*100001+B(:)
  call msort(A)
  do i = 1, N
     B(i)=mod(A(i),100001)
     A(i)=(A(i)-B(i))/100001
  end do
 
  sum=0
  count=0
  i=1
  do
     if(count>=M) then
        exit
     end if
     sum=sum+A(i)*B(i)
     count=count+B(i)
     last=i
     i=i+1
  end do

  if(count>M) then
     sum=sum-(count-M)*A(last)
  end if

  write(*,*) sum
  deallocate(A,B)
  stop
contains
  !merge sort
  recursive subroutine msort(array)
    implicit none
    integer(8) :: i, j, k, N, mid, array(:)
    integer(8), allocatable :: tmp(:)
    N=size(array)
    allocate(tmp(N))
    if(n==1) then
       return
    end if
    !1~mid,mid+1~nと前半,後半に分けてsort
    mid=n/2
    call msort(array(1:mid))
    call msort(array(mid+1:n))
    tmp=array
    !tmpの後半部分を左右反転
    do k = n, mid+1, -1
       tmp(k)=array(n+mid-k+1)
    end do
    !iは前半のリストのうちまだ見ていないものの最小値
    !jは後半のリストのうちまだ見ていないものの最小値
    !kは見た回数の合計
    i=1
    j=n
    do k = 1, n !1番左と一番右のうち小さい方をarrayに入れていく
       if(tmp(i)<=tmp(j)) then 
          array(k)=tmp(i)
          i=i+1
       else
          array(k)=tmp(j)
          j=j-1
       end if
    end do
    return
  end subroutine msort
 end program answer