try:
  N, x = map(int, input().split())
  a = map(int, input().split())
  a_ = sorted(a)
  cnt = 0
  for i in a_:
      if i<=x:
          cnt += 1
          x = x-i
      else:
          break
  print(cnt)
except EOFError:
  pass