n,m=map(int,input().split())
ame=list(map(int,input().split()))
ame=sorted(ame)
answer=0
for i in range(n):
    if m>=ame[i]:
        m=m-ame[i]
        answer=answer+1
    else:
        break
if  i==n-1 and m!=0:
    answer=answer-1
print(answer)