
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = []
num = a[0]
i = 1

while num <= x:
    num += a[i]
    if x - a[i] > 0:
        x -= a[i]
        b.append(a[i])
        i += 1
    else:
        b.append(max(0,a[i]))
        break
"""
print(a)
print(b)
print(num)
"""
ans = 0
for i in range(min(len(a),len(b))):
    if a[i] == b[i]:
        ans += 1
print(ans)

