N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0

for i in range(N):
    x -= a[i]
    if 0 < x:
        count += 1
        if a[i] == a[-1]:
            count -= 1
    if x == 0:
        count += 1
        break
print(count)
