N=int(input()) S=int(input()) A=list(map(int,input().split())) A.sort() count=0 for i in range(N): S-=A[i] if S<0: print(count) break else: count+=1