(* O(n log n) *)
Scanf.scanf "%d %d" @@ fun n x ->
  let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  Array.sort (-) a_s;
  let rest = ref x in
  let f i a =
    if a > !rest then (Printf.printf "%d\n" i; exit 0)
    else rest := !rest - a in
  Array.iteri f a_s;
  Printf.printf "%d\n" n