N,M=input().split() M=int(M) C=sorted(list(map(int,input().split()))) O=0 for A in C: if A>M:break else: M-=A O+=1 print(O)