package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()

	line := s.Text()
	fields := strings.Fields(line)
	x, _ := strconv.Atoi(fields[1])

	s.Scan()
	line = s.Text()
	fields = strings.Fields(line)

	var childs []int
	for _, f := range fields {
		i, _ := strconv.Atoi(f)
		childs = append(childs, i)
	}
	sort.Ints(childs)

	remain := x
	given := 0
	for _, child := range childs {
		remain = remain - child
		if remain >= 0 {
			given++
		}
		if remain <= 0 {
			break
		}
	}
	fmt.Println(given)
}
