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