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

arr.sort()
ans = 0
for consume_v in arr:
    if x >= consume_v:
        x -= consume_v
        ans += 1
    elif x > 0 and ans > 0:
        ans -= 1
    else:
        break
print(ans)