local mmi, mma = math.min, math.max
local n, m, k = io.read("*n", "*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local asum = {a[1]}
for i = 2, n do
  asum[i] = asum[i - 1] + a[i]
end
local b = {}
for i = 1, m do
  b[i] = io.read("*n")
end
local bsum = {b[1]}
for i = 2, m do
  bsum[i] = bsum[i - 1] + b[i]
end
local blim = m
local ret = 0
for i = 0, n do
  local az = i == 0 and 0 or asum[i]
  if k < az then break end
  while 0 < blim and k < az + bsum[blim] do
    blim = blim - 1
  end
  ret = mma(ret, i + blim)
end
print(ret)
