import java.util.Scanner

fun main(args:Array<String>){
    val sc=Scanner(System.`in`)

    var n=sc.nextInt()
    var x=sc.nextLong()
    var a=IntArray(n)
    var total=0L

    for (i in 0 until n){
        a[i]=sc.nextInt()
        total+=a[i]
    }

    when{
        x==total-> println(n)
        x>total-> println(n-1)
        x<total->{
            a.sort()
            var sum=0
            for (k in 0 until n){
                sum+=a[k]
                if (sum>x){
                    println(k)
                    break
                }
            }
        }
    }
}