n, x = map(int, input().split())
children = [int(i) for i in input().split()]
children.sort()
count = 0
for child in children:
  if x < child:
    break
  else:
    x -= child
    count += 1
print(count)