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

a.sort()
count = 0
for i in a:
    if i == x and i == a[-1]:
        count += 1
    elif i < x and i == a[-1]:
        break
    elif i <= x:
        count += 1
        x -= i
    else:
        break
print(count)