N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in a:
    x -= i
    count += 1
    if x == 0:
        break
    elif x < 0:
        count -= 1
        break
print(count)