local read = io.read
local insert = table.insert
local max = math.max
local abs, floor = math.abs, math.floor

local N, M, K = read("*n", "*n", "*n")
local A, B = {}, {}
---indexが1多いことに注意
local sumed_A, sumed_B = {0}, {0}
for i = 1, N do
	A[i] = read("*n")
	insert(sumed_A, sumed_A[i] + A[i])
end
for i = 1, M do
	B[i] = read("*n")
	insert(sumed_B, sumed_B[i] + B[i])
end

---[[i,jは1多いことに注意
local ans, j = 0, M + 1
for i = 1, N + 1 do
	if sumed_A[i] > K then
		break
	end
	while sumed_B[j] > K - sumed_A[i] do
		j = j - 1
	end
	ans = max(ans, i + j - 2)
end
--]]

print(ans)
