n,x = map(int,input().split())
a = [int(i) for i in input().split()]
a_new = sorted(a)
i = 0
while x>=0 and i < n:
    if x >= a_new[i]:
        x -= a_new[i]
    else:
        break
    i += 1
if x>0 and i>0:
    i -= 1
print(i)