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

module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let as_ = Array.init (n + 1) @@ function
    | 0 -> 0
    | _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort compare as_;
  Printf.printf "%d\n" @@ upper_bound 0 (n + 1) @@ fun i ->
    let ai = as_.(i) in
    as_.(i) <- 0;
    let m = Array.fold_left (fun m a ->
      IntSet.fold (fun a' m ->
        if k <= a + a' then m
        else IntSet.add (a + a') m) m m) (IntSet.singleton 0) as_ in
    as_.(i) <- ai;
    IntSet.for_all (fun a -> a + ai < k) m
