N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x >= 0:
        b += 1
    else:
        break
if x == 0:
    print(b)
else:
    print(b-1)