local n,m,k=io.read("n","n","n")
local a={[0]=0}
for i=1,n do
    a[i]=a[i-1]+io.read("n")
end
local b={[0]=0}
for i=1,m do
    b[i]=b[i-1]+io.read("n")
end

local max=0
local j=m
for i=0,n do
    if a[i]>k then
        break
    end
    while b[j]>k-a[i] do
        j=j-1
    end
    max=math.max(max,i+j)
end
print(max)