n, x = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort()
temp_x = x
for i in range(n):
  if temp_x > 0:
    temp_x += -a[i]
  else:
    ans = i
    break
  if i == n-1 and temp_x > 0:
    ans = n-1
print(ans)