N,x = map(int,input().split())
a = list(map(int, input().split()))

a.sort()

s = 0
counter = 0

if a[0] <= x:
    for i in range(N):
        if i != N-1:
            if s < x:
                s += a[i]
                counter += 1
            else:
                break
        else:
            if x - s == a[i]:
                counter += 1
            else:
                break

print(counter)
