let () = Scanf.scanf "%d %d %d\n" @@ fun n m k ->
  let as_ = Array.init (n + 1) @@ fun i ->
    if i = n
    then max_int
    else Scanf.scanf "%d " @@ fun a -> a in
  let bs = Array.init (m + 1) @@ fun i ->
    if i = m
    then max_int
    else Scanf.scanf "%d " @@ fun b -> b in
  let rec solve acc k i j =
    if k < as_.(i) && k < bs.(j)
    then acc
    else if as_.(i) <= bs.(j)
    then solve (1 + acc) (k - as_.(i)) (i + 1) j
    else solve (1 + acc) (k - bs.(j)) i (j + 1) in
  Printf.printf "%d\n" @@ solve 0 k 0 0
