N,M = map(int,input().split()) C = sorted(list(map(int,input().split()))) for i in range(N): if M >= C[i]: C[i], M = 0, M-C[i] else: break print(C.count(0))