n,x = map(int,input().split())
a = list(sorted(list(map(int,input().split()))))
print(a)
ans = 0
for i in range(n+1):
  if i == n:
    if x > 0:
      ans -= 1
  elif x > a[i]:
    x -= a[i]
    ans += 1
  elif x == a[i]:
    ans += 1
print(ans)