N, x = map(int, input().split())
a = sorted([int(i) for i in input().split()])
ans = 0

i = 0
while i < N and 0 < x:
    v = a[i]
    if x - v >= 0:
        x = x - v
        ans += 1
    i += 1

print(ans)