package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func receive() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, x := receive(), receive()

	a := make([]int, n)
	var sum int
	for i := 0; i < n; i++ {
		t := receive()
		a[i] = t
		sum += t
	}
	sort.Ints(a)

	switch {
	case x == sum:
		fmt.Println(n)
	case x > sum:
		fmt.Println(n - 1)
	case x < a[0]:
		fmt.Println(0)
	default:
		var ans int
		for i, rs := 0, x; i < n && rs > 0; i, rs = i+1, rs-a[i] {
			ans++
		}
		fmt.Println(ans)
	}
}
