fun main(args: Array<String>) {

    var (n, x) = readLine()!!.split(" ").map(String::toInt)
    val an = readLine()!!.split(" ").map(String::toInt)

    val sum = an.sum()
    val result = if (x > sum) {
        an.size - 1
    } else if (x == sum) {
        an.size
    } else {
        var c = 0
        for (num in an.sorted()) {
            if (x >= num) {
                c++
                x -= num
            } else {
                break
            }
        }
        c
    }
    println(result)
}



