import strutils, algorithm

proc input: string =
  while true:
    let tmp = readChar stdin
    if not isSpace tmp:
      safeAdd result, tmp
    elif tmp != '\r': break

var
  N, x = parseInt input()
  a = newSeq[tuple[i, v: int]]()
  i, ans = 0

for i in 0 ..< N:
  add a, (i + 1, parseInt input())

a = sortedByIt(a, it.v)

while i < N and x >= a[i].v:
  ans += 1
  x -= a[i].v
  i += 1

echo ans
