N, x = map(int, input().split())
a = map(int, input().split())
arr = sorted(a)
ptr = 0
cnt = 0
if sum(a) == x:
	print(N)
else:
	while ptr < N and x >= arr[ptr]:
		cnt += 1
		x -= arr[ptr]
		ptr += 1
		
	print(cnt if x == 0 else max(0, cnt-1))