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

sum_cost = 0
ans = 0
for v in a:
    sum_cost += v
    if sum_cost <= x:
        ans += 1
    else:
        sum_cost -= v
        break

if sum_cost != x:
    ans -= 1
print(max(ans, 0))