a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
e = 0
for i in c:
    d = min(i, b)
    if d == i:
        e += 1
        b -= i
    else:
        break

if b != 0:
    e = max(e-1, 0)
print(e)
exit()
