N, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
children = [0] * N
a.sort()
kashi = 0
n = N
if a[0] > x:
    print(0)
elif sum(a) == x:
    print(N)
else:
    for i in range(0,n):
        kashi += a[i]
        children[i] += 1
        if kashi > x:
            kashi -= a[i]
            children[i] -= 1
            break
#     print(kashi)
    if kashi == x:
        print(N - children.count(0))
    else:
        print(N - children.count(0) - 1)