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

lists.sort()
count = 0
for i in lists:
  if x >= i:
    count += 1
    x -= i
  else:
    break
for i in lists:
  if x >= i:
    count -= 1
    x -= i
  else:
    break
print(count)