N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)
        
print(total)