L=int(input()) W=list(map(int,input().split())) sum_W=sum(W) while sum_W>=L: sum_W-=max(W) W.remove(max(W)) print(len(W))