n, x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

cnt = 0
for i in a:
    if x >= i:
        x = x - i
        cnt = cnt + 1
    else:
        break
if x != 0 and cnt != 0:
    cnt = cnt - 1
print (cnt)
