n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
cnt = 0
for i in range(n):
  if a[i] <= x:
    x -= a[i]
    cnt += 1
  else:
    break
if x >= a[0]:
  cnt -= 1
print(cnt)