from typing import SupportsComplex


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:
    now_cost = sum_cost + v
    if now_cost > x:
        break
    else:
        sum_cost = now_cost
        ans += 1

if sum_cost - x != 0:
    ans -= 1

print(max(ans,0))