n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = sorted(a)

count = 0
minusPoint = 0
for i in range(n):
    if x - a[i] >= 0:
        count += 1
        x -= a[i]
if x == 0:
    print(count)
    exit()
elif count > 0:
    count -= 1
    x += a[count]
    for j in range(count, n):
        if x == a[j]:
            count += 1
            break
print(count)
