let () =
  Scanf.scanf " %d %d %d" @@ fun n m k ->
  let arr1 = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let arr2 = Array.init m (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let lst1 = Array.to_list arr1 in
  let lst2 = Array.to_list arr2 in
  (* 時間 t で、机B で読める本の冊数を返す *)
  let can_read t lst = List.fold_left
    (fun (t', n') b -> 
      if b <= t' then (t' - b, n' + 1) else (t', n'))
    (t, 0) lst in
  let now = ref 0 in
  (* A で n 冊 読む時、A と B 合計で何冊読めるか計算し、最大値を返す *)
  let h lst = List.fold_left 
    (fun (c', t') a -> (now := !now + 1; 
      let nokori = t' - a in
      let (a', b') = can_read nokori lst2 in
      if (c' < (!now + b')) then (!now + b', nokori)
      else (c', nokori)
    )) (0, k) lst in
  (fun (a, b) -> Printf.printf "%d" a) (h lst1)
  