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