# AtCorder-Candy Distribution Again

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

a = 0
i = 0
list.sort()

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

elif x >= list[0]:

    while x > 0 and x >= list[i]:
        x -= list[i]
        a += 1
        if i < n-1 and x < list[i+1]:
            break
        if i == n-1:
            a = n
            break
        i += 1

    print(a)
