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)

	cnt := 0
	for i := 0; i < len(a); i++ {
		x -= a[i]
		if x < 0 {
			break
		}
		cnt++
	}
	
	fmt.Println(cnt)
}