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


ans = 0
score_x  = x

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

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


print(ans)