N, M, K = io.read("*n","*n","*n")
A = {}; for i = 1, N do A[i] = io.read("*n") end
B = {}; for i = 1, M do B[i] = io.read("*n") end

a = {}; a[0] = 0
for i = 1, N do a[i] = a[i-1] + A[i] end

b = {}; b[0] = 0
for i = 1, M do b[i] = b[i-1] + B[i] end

ans = 0
for i = 0, N do
  if a[i] > K then break end
  left = 0
  right = M + 1
  while right - left > 1 do
    cur = (left + right) // 2
    if b[cur] <= K - a[i] then
      left = cur
    else
      right = cur
    end
  end
  ans = math.max(ans, i + left)
end

print(ans)
