N,x = list(map(int,input().split()))
A = list(sorted(list(map(int,input().split()))))
for i in range(N,0,-1):
    if sum(A[:i]) == x:
        print(i)
        break
    elif sum(A[:i]) < x:
        print(i-1)
        break
else:
  print(0)