
a=raw_input();
lt=a.split(' ')
n=int(lt[0])
x=int(lt[1])
b=raw_input()
lt=b.split(' ')
ar=[]
for i in range(0,n):
	ar.append(int(lt[i]))

ar.sort()
v=0
for i in range(0,n):
	if x<=0:
		break
	else:
		x-=ar[i]
		v+=1

if x!=0:
	v-=1
print(v)