program exams;
var 
    T: array[1..1000000] of int64;
    D: array[1..1000000] of int64;
    E: array[1..1000000] of int64;
    
    sum,i,j,maxel,n,count,k:int64;
    



begin
read(n);

for i:=1 to n do
begin
read(T[i]);
read(D[i]);
end;

for i:=1 to n do
E[i]:=D[i];


for i:=1 to n-1 do
for j:=1+i to n do
if E[i]>E[j] then
k:=E[i];
E[i]:=E[j];
E[j]:=k;






count:=n;
sum:=0;
maxel:=D[1];

for i:=1 to n do 
begin
sum:= sum + D[i];
maxel:=D[count];
if (T[i]<sum) then
begin
sum:=sum-maxel;
count:=count-1;
end;
end;

writeln(count);


end.
