n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(n):
    x = x - a[i]
    if x >= 0:
        continue
    else:
        print(i)
        break
if x >= 0:
    print(i+1)