[n,x] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
accsum = [0]
for i in range(n):
    if accsum[i] >= x:
        break
    accsum.append(accsum[i] + a[i])

#print(i)
#print(accsum)
if accsum[i+1] == x:
    print(i+1)
else:
    print(i)
