n, x = map(int, input().split(" "))
children = list(map(int, input().split(" ")))

children.sort()
if children[0] > x:
  print(0)
  exit()
  
count = 0
for i in range(n):
  x -= children[i]
  if x == 0:
    count += 1
    break
  elif x > 0:
    count += 1
  else:
    break
if x != 0:
  count -= 1
print(count)