package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sort.Ints(ar)
	sum := 0
	for _, v := range ar {
		if v <= x {
			sum++
			x -= v
		}
	}
	if sum != 0 && x > 0 {
		sum--
	}
	fmt.Println(sum)
}
