fun main(args: Array<String>) {
    var x = readLine()!!.split(' ')[1].toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }.sorted()
    var cnt = 0
    for (i in a) {
        if (x < i) break
        x -= i
        cnt++
    }
    if (x != 0 && cnt != 0) cnt--
    println(cnt)
}
