n, x = input().strip().split()
n,x = int(n), int(x)

a = [int(i) for i in input().strip().split()]
a.sort()

sum = 0
for i in range(n):
  sum += a[i]
  if(sum>x):
    print(i)
    break
else:
  if sum==n:
    print(n)
  else:
    print(n-1)
