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