fun main(args:Array<String>){
    val line1 = readLine()!!.trim().split(' ').map(String::toInt)
    val line2 = readLine()!!.trim().split(' ').map(String::toInt)
    val n = line1[0]
    val x = line1[1]
    val list = line2.sorted()
    var sum = 0
    var counter = 0
    for(ai in list){
        sum += ai
        if(sum>x)break
        counter++
    }
    if(sum<x)counter--
    println(counter)
    return
}