[N, x] = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
count = 0
i = 0
while x >= 0 and i <= len(a):
  x -= a[i]
  if i == len(a)-1:
    if x != a[i]:
      break
  if x >= 0:
    count += 1
  i += 1
  
print(count)