open Batteries

let n,m,k = Scanf.sscanf (read_line()) "%d %d %d" (fun n m k -> n,m,k)
let a = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> Array.of_list
let b = read_line () |> String.split_on_char ' ' |> List.map int_of_string |> Array.of_list
let all = (Array.length a) + (Array.length b)
let all_count = (Array.fold_left (fun k l -> k+l) 0 a) + (Array.fold_left (fun k l -> k+l) 0 b)

let rec main_loop a_where b_where time_count book_count =
  if k >= all_count then all else
  if a_where >= n && b_where >= m then book_count else
  if a_where >= n then (
    if time_count + b.(b_where) > k then book_count else
    main_loop (a_where) (b_where+1) (time_count + b.(b_where)) (book_count+1)
  ) else
  if b_where >= m then (
    if time_count + a.(a_where) > k then book_count else
    main_loop (a_where+1) (b_where) (time_count + a.(a_where)) (book_count+1)
  ) else
  (
    if time_count + a.(a_where) > k then (
      if time_count + b.(b_where) > k then book_count else
      main_loop (a_where) (b_where+1) (time_count + b.(b_where)) (book_count+1)
    ) else
    max (main_loop (a_where+1) (b_where) (time_count + a.(a_where)) (book_count+1)) (main_loop (a_where) (b_where+1) (time_count + b.(b_where)) (book_count+1))
  )
let _ = Printf.printf "%d\n" @@ main_loop 0 0 0 0