n, x = map(int, input().split())
l = sorted([*map(int, input().split())])
i = 0
for i in range(n):
    if l[i] <= x: 
        x -= l[i]
    else:
        break
if i == (n - 1) and x == 0: i += 1
print(i)