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

    val sum =aa.sum()!!
    if(sum<x){
        println(n-1)
    }else if(sum==x){
        println(n)
    }else{
        val asort = aa.sorted()
        var xsum = 0L;
        for (i in 0..n - 1) {
            xsum += asort[i.toInt()]
            if (xsum > x) {
                println(i)
                return
            }
        }

    }
}