N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in range(N):
    sum += children[i]
    if sum >= x:
        print(i + 1)
        break
    elif i == N - 1:
        print(N - 1)
