open System

let ReadIntArray() = Console.ReadLine().Split(' ') |> Array.map int64

let [|n; m; k|] = ReadIntArray() |> Array.map int
let A = ReadIntArray()
let B = ReadIntArray()

let GetPre (xs:int64[]) = 
    for i = 1 to xs.Length-1 do
        xs.[i] <- xs.[i-1] + xs.[i]
GetPre A
GetPre B

let GetUp (xs:int64[]) = 
    let mutable r = -1
    for i = 0 to xs.Length-1 do
        if xs.[i] <= int64(k) then 
            r <- i
    r

let mutable (pa, pb) = ((GetUp A), (GetUp B))

let mutable ans = max (pa + 1) (pb + 1)

pb <- -1

while (pa > -1) do
    while (pb + 1 < m) && (A.[pa] + B.[pb + 1] <= int64(k)) do
        pb <- pb + 1
    ans <- max ans (pa + pb + 2)
    pa <- pa - 1

Console.Write(ans)