N, x = map(int, input().split())
alist = list(map(int, input().split()))

max = 0
alist.sort()
for i in range(0, N):
  x -= alist[i]
  if x < 0:
    max = i
    break
  if x == 0:
    max = i + 1
    break
print(max)