N, x = map(int, input().split())
child_list = list(map(int, input().split()))

count = 0
for child in sorted(child_list):
  x -= child
  if x < 0:
    break
  count += 1

count = N if count >= N else count
print(count)