package main

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


func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	line := s.Text()
	fmt.Println(line)
	fields := strings.Fields(line)
	fmt.Println(fields)

	_ = fields[0]
	x, _ := strconv.Atoi(fields[1])

	s.Scan()
	line = s.Text()
	fmt.Println(line)
	childsStr := strings.Fields(line)
	childs := toInts(childsStr)
	sort.Ints(childs)

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

func toInts(ss []string) []int {
	var ints []int
	for _, s := range ss {
		i, _ := strconv.Atoi(s)
		ints = append(ints, i)
	}
	return ints
}
