n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
people = 0
sum = 0

for i in a:
    sum += i
    people += 1
    if sum >= x:
        break

if sum < x:
    people -= 1
elif x < min(a):
    people = 0

print(people)