N, x = map(int,input().split())
A = sorted(list(map(int, input().split())))
ans = 0
sum = 0
for i, A_i in enumerate(A):
	if sum + A_i <= x:
		ans = i + 1
		sum += A_i
	else:
		break
if sum != x:
	ans -= 1
print(ans)