fun main(args: Array<String>) {
    agc027a()
}

fun agc027a() {
    val (n, x) = readLine()!!.split(' ').map { it.toLong() }
    val aList = readLine()!!.split(' ').map { it.toLong() }
        .sorted().toLongArray()

    var remain = x
    var answer = 0L
    for (a in aList) {
        if (a <= remain) {
            remain -= a
            answer++
        } else break
    }

    if (answer == 0L) return println(0)

    if (answer == n && remain > 0) answer--

    println(answer)
}
