#CandyDistributionAgain
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
cnt = 0
for i in range(n):
  if x >= a[i]:
    cnt += 1
    x -= a[i]
if x == 0:
  print(cnt)
else:
  print(cnt - 1)