object Main extends App {
  var a = readLine.split(" ").map(_.toLong)
  var b = readLine.split(" ").map(_.toLong).sorted
  var sum = 0L
  for(i <- 0 until a(0).toInt - 1 if(a(1) >= b(i))) {
      a(1) = a(1) - b(i)
      sum = sum + 1
  }
    if(a(1) > b(a(0).toInt - 1)) {
      sum = sum - 1
    }
  print(sum)
}