package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	list := make([]int, a)
	for i := 0; i < a; i++ {
		fmt.Scan(&list[i])
	}

	sort.Ints(list)
	fmt.Println(list)

	count := 0
	for i := 0; i < a; i++ {
		fmt.Println(b, list[i], i)
		if b < list[i] {
			count = i
			break
		}
		b -= list[i]
		if b <= 0 {
			count = i + 1
			break
		}
		count = i
	}

	fmt.Println(count)

}
