# A
n,x = list(map(int, input().split()))
a = list(map(int, input().split()))
num = 0
for ai in sorted(a):
    if ai<=x:
        num+=1
        x-=ai
    else:
        break
if num>0 and x>0:
    num-=1
print(num)