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