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