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)

	max, count := 0, 0
	for _, v := range a {
		max += v

		if max <= x {
			count++
		} else {
			break
		}
	}

	fmt.Println(count)
}
