n, k = map(int, input().split())

a = list(map(int, input().split()))

sum = 0
ans = 0
a.sort()

for i in range(n):
    sum += a[i]
    if sum <= k:
        ans += 1
    else:
        break

print(ans)

