n,x = map(int,input().split())
a = list(map(int,input().split()))
b = 0

a.sort()
for i in a:
  x -= i
  b += 1
  if x == 0:
    break
  elif x < 0:
    b -= 1
    break
  elif x > 0 and i == max(a):
    b -= 1
    break
    
print(b)