n,x = map(int,input().split())
a = sorted(list(map(int,input().split())))

res = 0
for i in a:
    if x<=i:
        break
    x -= i
    res += 1
if x==0:
    print(res)
else:
    print(max(res-1,0))
