Program ABC121C

integer(8) n,m,c,p,x
integer(8),allocatable::a(:),b(:)

read(*,*) n,m
allocate(a(n))
allocate(b(n))
do i=1,n
 read(*,*) a(i),b(i)
end do

c=0
p=0

do i=1,n
 do j=i+1,n
  if (a(i)>a(j)) then
   x=a(i)
   a(i)=a(j)
   a(j)=x
   x=b(i)
   b(i)=b(j)
   b(j)=x
  end if
 end do
end do

do i=1,n
 c=c+a(i)*b(i)
 p=p+b(i)
 if (p>=m) then
  c=c-a(i)*(p-m)
  go to 10
 end if
end do
 
10 write(*,*) c

stop
end