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)

	sum, count := 0, 0

	if sum <= x {
		count = count -1
	}

	for _, v := range a {
		sum += v

		if v <= x {
			x -= v
			count++
		}
	}

	fmt.Println(count)
}
