fun main(args : Array<String>) {
    val (n, x) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var cnt = 0
    var given = 0
    var lastIndex = 0

    for(i in aa.indices) {
        if (given + aa[i] <= x) {
            given += aa[i]
            lastIndex = i
            cnt++
        } else {
            break
        }
    }

    if (cnt == 0) {
        println(0)
        return
    }

    if (given == x || lastIndex < n-1) {
        println(cnt)
    } else {
        println(cnt-1)
    }
}