n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

cnt = 0
for i in range(n):
    if a[i] <= x:
        cnt += 1
        x -= a[i]
    else:
        break

if x > 0:
    cnt -= 1

print(max(0, cnt))