n, x = map(int, input().split())
A = [int(i) for i in input().split()]

A.sort(reverse=True)
count = 0

for i in range(n):
    if x >= A[i]:
        x -= A[i]
        count += 1

if x != 0 and count != 0:
    count -= 1

print(count)