let lim = 10000
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.sort (-) a;

  let rec loop l r =
    if l >= r then r else
    let m = (l+r) / 2 in
    let x = a.(m) in
    let dp = Array.make (lim+1) false in
    dp.(0) <- true;

    a |> Array.iteri (fun i v -> 
      if i = m then () else
      for j = lim downto v do
        dp.(j) <- dp.(j) || dp.(j-v)
      done);

    Array.init x (fun i ->
      k-x+i >= 0 && dp.(k-x+i))
    |> Array.fold_left (||) false
    |> fun b -> if b then loop l m else loop (m+1) r
  in

  loop 0 n |> Printf.printf "%d\n"