N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
count = 0
if x < a[0]:
    print(0)
    exit()

for i in range(N):
    if x >= a[i]:
        x = x - a[i]
        count += 1
    else:
        break
if x > 0:
    print(count - 1)
else:
    print(count)