n, x = map(int, input( ).split())
a = list(map(int, input().split()))
counter = 0
for i in sorted(a):
  x -= i
  counter += 1
  if x < 0:
    print(counter-1)
  elif x == 0:
    print(counter)
  if counter == n and x>0:
    print(n-1)
  elif counter == n and x==0:
    print(n)