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