N, x = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ")]

lst.sort(reverse = True)
cnt = 0

for i in range(0,N):
  x -= lst[i]
  if x >= 0:
    cnt += 1
  else:
    break
    
print(cnt)