N,x = map(int,input().split())
List = list(map(int, input().split()))
Sorted = sorted(List)
A = B = 0
if sum(List) == x:
    print(N)
elif sum(List) < x:
    print(N-1)
else:
    for i in Sorted:
        B += 1
        A += i 
        if A == x:
            print(B)
            break
        else:
            print(B-1)
            break
            