open Batteries

let calc x li =
  let rec aux c = function
    | [] -> c
    | a :: al when a + c <= x -> aux (1 + c) al
    | a :: al -> c
  in
  aux 0 li

let () =
  Scanf.scanf " %d %d " (fun n x ->
      let cs = List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
      let sum = List.fold_left ( + ) 0 cs in
      ( if sum = x then n
      else
        let ans = cs |> List.sort compare |> calc x in
        if ans = n then n - 1 else ans )
      |> Printf.printf "%d\n" )
