N, x = map(int, input().split())
arr = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    if x >= arr[i]:
        x -= arr[i]
        ans += 1
    else:
        break
if x != 0:
    ans -= 1
print(max(ans,0))