# AtCorder-Candy Distribution Again

n,x = map(int, input().split())
list = list(map(int, input().split()))

a = 0
list.sort()
i = 0

if x < list[0]:
    print(0)

elif x >= list[0]:
    # x -= list[i]
    # print(x)
    while x >= 0:
        x -= list[i]
        a += 1
        i += 1
        if i == n-1 or x == 0:
            a += 1
            break
    # print(x)
    print(a)


    # return print(a)
