n,s=map(int,input().split())
arr=list(map(int,input().split()))
a=sorted(arr)
d=[-1]*(n)
x=s
for i in range(n):
	if x<a[i]:
		break
	d[i]=(a[i])
	x=x-a[i]
	if(x<=0):
		break

cnt = 0
for i in range(n):
	if(a[i] == d[i]):
		cnt = cnt+1
if(x > 0 and cnt !=0):
	cnt = cnt-1
print(cnt)