n=int(input()) r=int(input()) s=list(map(int,input().split())) s.sort() c=0 for i in range(0,r): c += s[i] if n=c: print(r)