n, x = map(int, input().split())
l = list(map(int, (input().split())))
l.sort()
count = 0
total = 0
for i in range(len(l)):
    if total + l[i] > x:
        break
    total += l[i]
    count += 1
if (x - total > 0) & (total != 0):
    print(count-1)
else:
    print(count)