import Foundation
var rd = readLine()!.split(separator: " ").map({Int($0)!})
let rdSnack = readLine()!.split(separator: " ").map({Int($0)!}).sorted()

let N = rd[0]
var x = rd[1]
var count = 0

if rdSnack[0] <= x {
 


for i in 0 ..< N {
    
    if x <= 0 {
       
        break
    }
    x -= rdSnack[i]
    
    count += 1
    //print("countがインクリメントされた")
}

if x > 0 {
    print(count - 1)
}else {
print(count)
}
}
else {

    print(0)
}