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