program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;
const max=200000;
type part=record
  a,k:int64;
end;
type list=array[1..max] of part;
procedure qsort(lo,hi:int64;var a:list);
procedure sort(l,r:int64);
var
i,j,p:int64;
y:part;
begin
  i:=l; j:=r; p:=a[(l+r) div 2].k;
  repeat
    while a[i].k<p do i:=i+1;
    while a[j].k>p do j:=j-1;
    if i<=j then
    begin
      if a[i].k>a[j].k then
      begin
        y:=a[i]; a[i]:=a[j]; a[j]:=y;
      end;
      inc(i);
      dec(j);
    end;
  until i>=j;
  if l<j then sort(l,j);
  if i<r then sort(i,r);
end;
begin
  randomize;
  sort(lo,hi);
end;

var
  n,s,a,k,all,d:int64;
  c:list;
  i:integer;
begin
  assign(input,'castle.in');
  assign(output,'castle.out');
  reset(input);
  rewrite(output);
  readln(n,s);
  all:=0;
  for i:=0 to n-1 do
  begin
    readln(a,k);
    inc(all,a);
    c[2*i+1].a:=k*(a div k);
    c[2*i+1].k:=k;
    c[2*i+2].a:=a mod k;
    c[2*i+2].k:=a mod k;
  end;
  qsort(1,2*n,c);
  i:=2*n+1;
  while (s>0) do
  begin
    dec(i);
    if c[i].k=0 then break;
    if c[i].a>c[i].k*s then
    begin
      dec(all,c[i].k*s);
      break;
    end;
    d:=c[i].a div c[i].k;
    dec(s,d);
    dec(all,d*c[i].k);
  end;
  write(all);
  close(input);
  close(output);
end.
 