num_children, num_snacks = list(map(int, input().split(' ')))
children = list(map(int, input().split(' ')))
children.sort()

count = 0
for i in range(num_children):
  if num_snacks >= sum(children[:i+1]):
    count += 1
print(count)

