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

ans = 0
score_x  = x

for  i in range(N):
    if score_x < a[i]:
        print(0)
        sys.exit()

    elif score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1

print(ans)