input_N_x = readline(STDIN)
input_a_arr = readline(STDIN)
N, x = map(x -> parse(Int64,x), split(input_N_x))
a_arr = sort(map(x -> parse(Int64,x), split(input_a_arr)), rev=true)
count = 0 
while length(a_arr) > 0
    value = pop!(a_arr)
    x = x - value
    if x < 0
        break
    else
        count = count + 1
    end
end

if (length(a_arr) == 0).&(x > 0)
    print(count - 1)
else
    print(count)
end