N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range(N):
    if a[i] <= x:
        if x - a[i] >= 0:
            x -= a[i]
            count += 1
    else:
        break
if x != 0:
    count -= 1
if count < 0:
    print(0)
else:
    print(count)
