package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

	if x < a[0] {
		fmt.Println(0)
		return
	}

	var ans int
	for _, v := range a {
		if x <= 0 {
			break
		}
		x -= v
		ans++
	}

	if x > 0 {
		ans--
	}

	fmt.Println(ans)
}
