type t= array [1..100000] of longint;{1 a, 2 k}
var s: array [1..100000,1..2] of longint;
    s1: t;
    s2:t;
    k: int64;
    i,n,s0: longint;
procedure qsort(var a : t);

    procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;

    begin
       sort(1,n);
    end;              
begin
readln (n,s0);
k:=0;
for i:=1 to n do begin
read (s[i,1],s[i,2]);
k:=k+s[i,1];
end;
k:=k-s0;
if k<0 then k:=0;
writeln (k);
end.