n,x=map(int,input().split())
children = sorted(map(int,input().split()))
if sum(children) == x:
    print(n)
else:
    sum = 0
    cnt=0
    for i in children:
        if sum + i > x:
            break
        sum += i
        cnt += 1
    print(cnt)
