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)
  else:
    if counter==n:
      print(counter-1)