n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

cnt = 0
asum = 0
for i in range(n):
    if asum <= x and a[i] <= x:
        cnt += 1
        asum += a[i]
    else:
        break

if asum < x and asum != 0:
    print(cnt - 1)
else:
    print(cnt)