program N3;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var n,s,i,o,y1,kl:longint;
       c1,c:int64;
      a,k,q,w,w1:array [0..100000] of longint;
 procedure qsort(l,r:longint);
  var f,i,j,p:longint;
   begin
     i:=l;
     j:=r;
     f:=k[(l+r) div 2];
     while i<j do
      begin
     while k[i]<f do i:=i+1;
     while k[j]>f do j:=j-1;
      if i<=j then
       begin
        p:=k[i];
        k[i]:=k[j];
        k[j]:=p;
        p:=a[i];
        a[i]:=a[j];
        a[j]:=p;
        i:=i+1;
        j:=j-1;
       end;

      end;
     if j>l then qsort(l,j);
     if r>i then qsort(i,r);
   end;
   procedure qsort1(l,r:longint);
  var f,i,j,p:longint;
   begin
     i:=l;
     j:=r;
     f:=w1[(l+r) div 2];
     while i<j do
      begin
     while w1[i]<f do i:=i+1;
     while w1[j]>f do j:=j-1;
      if i<=j then
       begin
        p:=w1[i];
        w1[i]:=w1[j];
        w1[j]:=p;

        i:=i+1;
        j:=j-1;
       end;

      end;
     if j>l then qsort1(l,j);
     if r>i then qsort1(i,r);
   end;
begin
 assign(input,'castle.in');
 reset(input);
 assign(output,'castle.out');
  rewrite(output);
 readln(n,s);
 c:=0;
 for i:=1 to n do
  begin
  readln(a[i],k[i]);
  c:=c+a[i];
  end;
 close(input);
   qsort(1,n);
   o:=0;
   
    for i:=n downto 1 do
      begin
        if s>=a[i] div k[i] then
         begin
           s:=s-(a[i] div k[i]);
            o:=o+1;
            q[o]:=a[i] div k[i];
            w[o]:=k[i];
            w1[o]:=a[i] mod k[i];
         end
          else
           begin
            if s<>0 then
            begin
             o:=o+1;
             q[o]:=s;
             w[o]:=k[i];
             s:=0;
             end;
             break;

           end;

      end;
      

     qsort1(1,o);


      i:=o+1;
      c1:=0;
     while (s<>0)and(i>=1) do
        begin
         i:=i-1;
         s:=s-1;
         c1:=c1+w1[i];
        end;
      kl:=i;

     y1:=o;

     for i:=1 to o do
      c1:=c1+q[i]*w[i];



     for i:=kl-1 downto 1 do
      begin
       while (q[y1]=0)and(y1<>0) do
         y1:=y1-1;
        if y1=0 then break; 
       if w1[i]>w[y1] then
        begin
          c1:=c1+w1[i]-w[y1];
          q[y1]:=q[y1]-1;
          if q[y1]=0 then y1:=y1-1;
          if w1[i]<=w[y1] then break;
        end;
      end;



    writeln(c-c1);
  close(output);   
end.

