N, x = map(int, input().split())
a = map(int, input().split())
a_sorted = sorted(a)
if sum(a_sorted) <= x:
  print(N)
else:
  i = 0
  a_sum = 0
  while a_sum <= x:
    a_sum += a_sorted[i]
    i += 1
  print(i - 1)