var q,w,e,n,s,i,j:longint;
    a:array[1..100000,1..2]of integer;
    t:text;
begin
assign(t,'castle.in');
reset(t);
readln(t,n,s);
for i:=1 to n do
begin
readln(t,q,w);
inc(j,q);
end;
close(t);
assign(t,'castle.out');
rewrite(t);
if j<s then writeln(t,0)else writeln(t,j-s);
close(t);
end.
