fun main(array: Array<String>) {
    var (n, x) = readLine()!!.split(" ").map{ it.toInt()}
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var cnt = 0
    var sum = x
    repeat(n) {
        sum -= a[it]
        println(sum)
        if(sum >= 0) {
            cnt++
        }
        else {
            print(cnt)
            return
        }
    }
    if(0 < sum && cnt == n) cnt--
    print(cnt)
}