N,M = [int(x) for x in input().split()] C = [int(x) for x in input().split()] C.sort() for i in range(N): M -= C[i] if M<0: print(i-1) exit() else: print(N)