package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, x int
	fmt.Scan(&N, &x)

	a := make([]int, N)
	for i:=0; i<N;i++ {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	count := 0
	for _, v := range a{
		if x >= v {
			x -= v
			count++
		} else {
			break
		}
	}

	fmt.Println(count)
}
