N,M=map(int,raw_input().split()) C=map(int,raw_input().split()) C.sort() ans = 0 for c in C: M-=c if M>=0: ans+=1 else: break print ans