N, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = 0

for i in range(N):
  if x >= a[i]:
    cnt += 1
    x -= a[i]
  else:
    pass

if x != 0 and cnt != 0:
  cnt -= 1
else:
  pass

print(cnt) 