from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))

result = 0
break_idx = 0
for i, x in enumerate(p):
  if X < x:
    break_idx = i
    break
  result += 1
  
if result != 0 and p[break_idx-1] != X:
  result -= 1

print(result)