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 total == x:
    print(count)
else:
    if count-1 < 0:
        print(0)
    else:
        print(count-1)