let input=readLine()!.characters.split(" ").map{Int(String($0))!}
let N=input[0]
var x=input[1]
let a=readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
var ans=N-1
for i in 0..<N {
  x-=a[i]
  if x<=0 {
    ans=i+(x<0 ?0:1)
    break
  }
}
print(ans)