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()
for i in 0..<N {
  x -= a[i]
  if x <= 0 {
    print(i + Int(x==0))
    break
  }
}
if x>0{print(N-1)}