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