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

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

    if (given != x) cnt -= 1

    println(Math.max(0, cnt))
}