n,x = map(int, input().split())
ls = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
    if x >= ls[i] or x == ls[i]:
        x -= ls[i]
        ans += 1
    else:
        break
print(ans)