def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n,x=i2()
a=intl()
a.sort()
b=0
for i in range(n):
	x-=a[i]
	if x>=0:
		b+=1
	if x<0:
		break
print(b)