N, M, *C = map(int, open(0).read().split()) C.sort() for i in range(N): M -= C[i] if M < 0: break print(i + 1)