open Printf open Scanf
open Array

let binary_search ng ok f =
  let d = if ng <= ok then 1 else -1 in
  let rec f0 ng ok =
    if abs (ok - ng) <= 1 then ok
    else let mid = ng + (ok - ng) / 2 in if f mid then f0 ng mid else f0 mid ok
  in f0 (ng-d) (ok+d)

let () = scanf " %d %d" @@ fun n k ->
  let a = init n (fun _ -> scanf " %d" @@ fun v -> v) in
  sort compare a;
  print_int @@ binary_search 0 (n-1) (fun i ->
    let u = a.(i) in
    if u >= k then true
    else (
      let f = ref false in
      let dp = make (k+1) false in
      dp.(u) <- true;
      iteri (fun j v ->
        if j=i then ()
        else (
          for w=k downto 1 do
            if dp.(w) then (
              if k <= w+v && w+v < k + u then
                f := true
              else if w+v < k then
                dp.(w+v) <- true
            )
          done
        );
      ) a; !f
    )
  )



