N,M = map(int,input().split())
C = list(map(int,input().split()))
C.sort()
count = 0
now = 0
for i in C:
    if i + now <= M:
        count += 1
        now += i
    else:
        break
    
print(count)