N,M = map(int,input().split()) lsC = list(map(int,input().split())) lsC.sort(reverse=True) while lsC and M > 0: if lsC[-1] <= M: M -= lsC.pop() else: break print(N-len(lsC))