N, x = map(int,input().split())
A = sorted(list(map(int, input().split())))
ans = 0
sum = 0
for i in range(N):
	if sum + A[i] < x:
		ans = i
		sum += A[i]
	elif sum + A[i] == x:
		ans = i + 1
		sum += A[i]
	else:
		break
print(ans)
