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

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

if x > 0:
    print(ans-1)
elif x <= 0:
    print(ans)