N, x = map(int, input().split())
children = list(map(int, input().split()))
ans = 0

children = sorted(children)
for i in children:
  if x < i:
    break
  elif x == i:
    ans += 1
    break
  elif i == max(children):
    break
  else:
    x -= i
    ans += 1
    
print(ans)