N, x = map(int, input().split())
a = sorted(map(int, input().split()))

ans = 0
for i in range(N):
    if x < a[i]:
        break
    x -= a[i]
    if x < 0:
        break
    ans += 1
if x > 0:
    ans -= 1
print(max(ans, 0))