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