N,x = map(int,input().split())
a = sorted([int(x) for x in input().split()])
ans = 0
if a[0] > x:
  print(0)
  exit()
for i in a:
  if x-i >= 0:
    x -= i
  else:
    break

  ans += 1

print(ans if x == 0 else ans - 1)