L=int(input()) W=sorted(list(map(int,input().split()))) sum_W=sum(W) while sum_W>L: sum_W-=max(W) del W[-1] print(len(W))