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

s = 0
num = 0
for i in range(len(a)):
    if x >= a[i]:
        x -= a[i]
        num += 1
    else:
        break

print(num)