let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort compare as_;
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- acc.(i) + as_.(i)
  done;
  let i = upper_bound 0 (n + 1) @@ fun i -> acc.(i) <= x in
  Printf.printf "%d\n" @@ max 0 @@ i - if acc.(i) = x then 0 else 1