let () =
  Scanf.scanf " %d %d %d" @@ fun n m k ->
  let lst1 = List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let lst2 = List.init m (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  
  let b = ref (List.length lst2) in
  let bsum = ref (List.fold_right ( + ) lst2 0) in
  
  let rec can_read t lst = 
    if t >= !bsum then (!b, lst)
    else match lst with
      | [] -> (!b, [])
      | first :: rest ->
        (b := !b - 1; bsum := !bsum - first;
         if t >= !bsum then (!b, rest)
         else can_read t rest) in
                                
  let a = ref 0 in

  let rec h2 (max, t) l1 l2 = match l1 with
    | [] -> (max - 1, t)
    | first :: rest ->
      let nokori = t - first in
      if nokori >= 0 then
        (a := !a + 1;
         let (b_num, b_lst) = can_read nokori l2 in
         if (max < !a + b_num) then
           h2 (!a + b_num, nokori) rest b_lst
         else h2 (max, nokori) rest b_lst
        )
      else (max - 1, t) in

  let ans = h2 (0, k) (0 :: lst1) (List.rev lst2) in
  (fun (a, b) -> Printf.printf "%d" a) ans