N, x = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array, reverse=False)
#print(array)
for i in range (N):
  if sum(array) < x:
    print(N)
    break
  elif sum(array[0:i+1]) == x:
    print(i)
    break
  elif sum(array[0:i+1]) < x and x < sum(array[0:i]):
    print(i-1)
    break
  else:
    pass