N, x = map(int, input().split())
a = [int(x) for x in input().split()]

a.sort()
ans = 0

for i in range(N):
	if x >= a[i]:
		ans += 1
		x -= a[i]
	else:
		break

if x > 0 and ans != 0:
	ans -= 1
print(ans)