import sequtils, strutils, algorithm, math, future, sets, tables, hashes, system

let read = iterator : string {.closure.} = (while true : (for s in stdin.readLine.split : yield s))


proc solve() =
   
   var
      n,x = read().parseInt
      a = newSeq[int](n).mapit(read().parseInt)
      ans = 0
      
   a.sort(system.cmp)
   for i in 0 ..< n : 
      if x < a[i] : 
         break
      if i == n - 1 : 
         if x == a[i] : 
            ans += 1
            break
         else : 
            break
      x -= a[i]
      ans += 1

   echo ans 

solve()