open Printf
open Scanf

let id x = x
let pair x y = x, y

let n, x = scanf "%d %d" pair
let vs = Array.init n @@ fun _ -> scanf " %d" id

let () =
    Array.sort (fun x y -> x - y) vs;
    let count = ref 0 in
    let rest = ref x in
    for i = 0 to n - 1 do
        if vs.(i) <= !rest then begin
            incr count;
            rest := !rest - vs.(i)
        end else begin
            printf "%d\n" !count;
            exit 0
        end 
    done;
    if !rest <> 0 then decr count;
    printf "%d\n" !count