object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n , x = sc.nextInt()
  var a = Array.fill(n)(sc.nextInt()).sorted
  var ans = 0
  for (i <- 0 until n if x >= a(i) & !(x - a(i) != 0 & i == n-1)){
    x -= a(i)
    ans += 1
  }
  println(ans)
}
