n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in a:
    if x-i>=0:
        x -= i
        count += 1
if count != n:
    print(count)
else:
    print(n-1)
