N,x = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
for i in range(len(l)):
    sum_l = sum(l[:i+1])
    if sum_l > x and sum(l[:i])== x:
        print(i)
        break
else:
    print(N)