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)

	ans := 0
	for i := 0; i < n; i++ {
		if a[i] <= x {
			ans++
			x -= a[i]
		}
	}
	if ans > 0 && x < 0 {
		ans--
	}

	fmt.Println(ans)
}
