n,x = map(int,input().split())
a_inputs = sorted([int(i) for i in input().split()])

ans=0
while a_inputs:
    if a_inputs[0]>x:
        break
    else:
        a = a_inputs.pop(0)
        x-=a
        ans+=1
if x!=0 and ans!=0:
    ans-=1
print(ans)
