module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let m =
    Array.fold_left (fun m a ->
      let le, _, _ = IntMap.split (x - a + 1) m in
      IntMap.fold (fun s n m ->
        IntMap.add (s + a)
          (max (n + 1) @@
            try IntMap.find (s + a) m
            with Not_found -> 0) m) le m) (IntMap.singleton 0 0) as_ in
  Printf.printf "%d\n" @@
    try IntMap.find x m
    with Not_found -> IntMap.fold (fun _ n -> max (n - 1)) m 0