N,x = map(int, raw_input().split())
a = map(int, raw_input().split())

S = sum(a)
if x>S:
  print N-1
elif x==S:
  print N
else:
  a.sort()
  ans = 0
  for t in a:
    if x>=t:
      x -= t
      ans += 1
  print ans
