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