object Main extends App {
	val Array(t1, t2) = scala.io.StdIn.readLine.split(" ")
	val n = t1.toInt
	val x = t2.toLong
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong).sorted

	var cnt = 0
	var ans = x

	while(ans > 0L && cnt < n){
		ans -= a(cnt)
		cnt += 1
	}

	if(ans == 0L){
		println(cnt)
	}else{
		println(cnt - 1)
	}
}