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 k ->
  let as_ = Array.init (n + 1) @@ function
    | 0 -> 0
    | _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort compare as_;
  let bs = Array.make k false in
  bs.(0) <- true;
  Printf.printf "%d\n" @@ upper_bound 0 (n + 1) @@ fun i ->
    if k <= as_.(i) then false
    else begin
      Array.fill bs 1 (k - 1) false;
      Array.iteri (fun j a ->
        if i <> j then
          for a' = k - 1 downto a do
            bs.(a') <- bs.(a') || bs.(a' - a)
          done) as_;
      try
        for a = k - as_.(i) to k - 1 do
          if bs.(a) then raise Not_found
        done; true
      with Not_found -> false
    end
