open Printf
open Scanf

let id x = x

let n, m, k = scanf "%d %d %d\n" (fun n m k -> n, m, k)
let aIn = Array.init n (fun i -> scanf "%d " id)
let bIn = Array.init m (fun i -> scanf "%d " id)

exception Break

let main () =
    let aa = Array.make (n + 1) 0 in
    let sum = ref 0 in
    for i = 1 to n do
        sum := !sum + aIn.(i - 1);
        aa.(i) <- !sum
    done;
    let bb = Array.make (m + 1) 0 in
    sum := 0;
        for i = 1 to m do
        sum := !sum + bIn.(i - 1);
        bb.(i) <- !sum
    done;
    let maxCount = ref 0 in
    for i = 0 to n do
        for j = 0 to m do
            let count = i + j in
            let total = aa.(i) + bb.(j) in
            if total <= k then begin
                if count > !maxCount then begin
                    maxCount := count
                end
            end
        done
    done;
    Printf.printf "%d\n" !maxCount

let () = main ()
