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

a.sort(reverse=True)

cnt = 0
for i in range(n):
    if i == n - 1:
        if x == a[i]:
            cnt += 1
    elif x >= a[i]:
        x -= a[i]
        cnt += 1
print(cnt)
