package main

import (
	"fmt"
	"sort"
)
func main() {
	var n,x int
	var a []int
	fmt.Scan(&n,&x)
	nn := n
	for nn >0{
		var i int
		fmt.Scan(&i)
		a = append(a,i)
		nn --
	}
	fmt.Scan(&a)
	//n = 3
	//x = 70
	//a = []int{20,30,10}

	fmt.Println(n,x,a)

	sort.Ints(a)

	var aa []int
	for _,i := range a{
		if i > x{
			break
		}
		x = x - i
		aa = append(aa,i)
		//log.Println(x,i)
	}

	fmt.Println(len(aa))

}