NX = input()
NX = NX.split(' ')
N = int(NX[0])
x = int(NX[1])
A = input()
A = list(map(int, A.split(' ')))
sorted_a = sorted(A)
s = 0

cum_sum = [0] * (len(sorted_a))
for i, a in enumerate(sorted_a):
    s = s + a
    cum_sum[i] = s

for i, s in enumerate(cum_sum):
    if s > x:
        print(i)
        break

if i == len(cum_sum)-1 and s == x:
    print(i+1)