N=int(input()) F=[] for _ in range(N): w,s=map(int,input().split()) F.append((w,s)) F.sort(key=lambda x:sum(x)) W=0 K=0 for w,s in F: if W<=s: W+=w K+=1 print(K)