<?php
  class Scanner 
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class Out 
{
    public static function println($str = "")
  {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$N = $sc->nextInt();
$x = $sc->nextInt();
$num[] = $sc->nextInt();
$num[] = $sc->nextInt();
$num[] = $sc->nextInt();
sort($num);

if ($num[0] > $x) {
  $answer = 0;
} elseif ($num[0] + $num[1] > $x) {
  $answer = 1;
} elseif (array_sum($num) > $x) {
  $answer = 2;
} else {
  $answer = 3;
}

$ln = new Out;
$ln->println($answer);
  
