def f(): l,n,t = int(input()),input(),0 for i,v in enumerate(sorted(map(int,input().split()))): t += v if t > l: return i return n print(f())