function main()
	nx = parse.(split(readline()))
	a = parse.(split(readline()))
	l = nx[1]
	for i in 1:l
		for j in 1:l-1
			if a[j] > a[j+1]
				temp = a[j+1]
				a[j+1] = a[j]
				a[j] = temp
			end
		end
	end

	sum = 0
	count = 0
	while sum < nx[2]
		if count == nx[1]
			break
		else
			count += 1
			sum = sum + a[count]
		end
		if sum == nx[2]
			count +=1
		end
	end
	return(count-1)
end


main()