package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, x int
	fmt.Scan(&N, &x)
	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	cnt := 0
	for i, v := range a {
		if v > x {
			continue
		} else {
			cnt++
			x -= v
		}
		if i == (N-1) && x > 0 {
			cnt--
		}
	}
	fmt.Println(cnt)
}
