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